wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes About serialVersionUID Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "About serialVersionUID" Watch "About serialVersionUID" New topic
Author

About serialVersionUID

Tanzy Akhtar
Ranch Hand

Joined: Jul 19, 2009
Posts: 110
Hi,

Can somebody explain what is serialVersionUID and when to define in the class?

I saw such a class having serialVersionUID defined more than once and with the same name and value like

What's the need of this?

Thanks,
Tanzy.


Roll with punchers, there is always tomorrow.
Techie Blog -- http://jtanzy.blogspot.com/
manoj r patil
Ranch Hand

Joined: Jun 06, 2002
Posts: 181
Just google it, and you will get what it is used for. In short, it is used in serialization by JVM.

I was wondering how come you can have serialVersionUID defined more than once. In fact you can not have any variable definition more than once at the same level (class/local).


love your job and not your company;
...because you never know when your company will stop loving you!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37902
    
  22
The idea of the SUIDis that when you have two instances of the same class with the same SUID, the JVM assumes they are from the same class object. If you have different SUIDs, the JVM may assume they are from different versions of the class, and the objects may not be de-serialized.
And I agree it is very peculiar to have two definitions in the same class.
 
 
subject: About serialVersionUID
 
Similar Threads
java.io.InvalidClassException
private static final long serialVersionUID = 1L; - Don't exist unique at a class that extends...
extending class with serialVersionUID
class versioning
sending org.jdom.Document object over JMS