what is Serialiable class for ?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: what is Serialiable class for ?

  1. #1
    Join Date
    Mar 2004
    Location
    malaysia
    Posts
    150

    what is Serialiable class for ?

    why some class need to implement Serialiable class? what is Serialiable class? why need it? I saw this in hibernate's persistance class that implements this class but i do not know why need this. I do not understand those low level thing in java. Help pls?

  2. #2
    Join Date
    Dec 2003
    Location
    tx/us
    Posts
    131
    A class needs to be serializable for it to exist somewhere other than in memory. It has to be serialized to pass it over the network or to be shared across multiple servers.

  3. #3
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    Serializable is an interface that "defines" two methods, readObject and writeObject.
    I write "defines" because you will not get a compilation error if you declare a
    class as serializable without implementing these two;
    Code:
    private void writeObject(java.io.ObjectOutputStream out)
         throws IOException
     private void readObject(java.io.ObjectInputStream in)
         throws IOException, ClassNotFoundException;
    As it works; the writeObject method writes the data to the stream and readObject
    must be designed to read the same data, in the same sequence, back again.
    eschew obfuscation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center