January 21st, 2003, 01:31 PM
Why would I need to implement the Serializable interface and what does it do?
January 21st, 2003, 03:45 PM
it implements the possibility to write your class´s state to a stream. "state" refering here to anything you need/want.
you can eg. implement "save" functions for text fields and user-defined GUIs (i.e. the user can modify his GUI layout and the layout is restored on re-starting the app). and many more....
"serializing" is the process where you store all important information for a class into a stream (even a string? - not sure...)
January 23rd, 2003, 01:23 AM
Serialization allows you to maintain persistence across machine reboots, networks etc. via (as mentioned before) sending it to a byte stream. This stream can be written to a file & then the object recreated (including state), called deserialization once returned to the Java environment.
Objects can also be "piped" to another Java enabled machine via RMI (Remote Method Invocation)...actually its very cool stuff but has a bit of a learning curve.
Fields that will NOT be saved during the serialization process are marked transient, static variables will also not be saved. If you new to the game I wouldnt worry about this quite yet. Once you have the basics & some advanced ideas soaked up then you can dive into this.