File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Spring in Action this week in the Spring 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: 39396
    
  28
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About serialVersionUID