Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

serialize main() 1

Status
Not open for further replies.

ElvisUntot

Programmer
Jan 8, 2002
72
DE
is it possible to serialize the main() class?

if anyone could do a bit of magic and provide some code, i would be very happy.
 
I'm not really up on serialisation, but as I understood it, once you implemented the Serializable class -then this made your entire class (including main()) serializable ...

Ben
 
i do think the same thing, but i do not know how to write the code.

...

i think i got a few steps further, i can serialize objects, but i can not cast an class into an object....
Code:
SerializeAndDeserializeDate.java:9: main(java.lang.String[]) in SerializeAndDeserializeDate cannot be applied to ()
                        Object x = (Object) main();
                                            ^
 
can you show me your code so far ...
 
ElvisUntot wrote:
i think i got a few steps further, i can serialize objects, but i can not cast an class into an object....

Your problem is that you are trying to put the results of a call to main(String[]) (an incorrect call btw) into an Object. main(String[]) returns void, this means that the results can never be stored in an Object. Serialization has nothing to do with methods. Serialization is strictly a way of persisting the state of objects. A method is not an object, it is merely an operation that can be performed on objects. It makes no sense to try and serialize a method.
 
>Serialization is strictly a way of persisting the state of objects. A method is not an object, it is merely an operation that can be performed on objects. It makes no sense to try and serialize a method.

Ok. Now I know what was wrong.

Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top