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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "serial" Watch "serial" New topic
Author

serial

arjun krishna
Greenhorn

Joined: Mar 02, 2006
Posts: 7
Can any body explain me what is the serialVersionUID ?
Where it is used?
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Moving to Java in General -- this is a question about Java, not Object-Oriented Scripting.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18545
    
  40

Originally posted by arjun krishna:
Can any body explain me what is the serialVersionUID ?
Where it is used?


When you serialize an object to a datastream, one of the items created is a version ID. It is basically some sort of checksum based on the instance variables, their types, etc. They way, if you change the class, and try to create an instance from the serialize data, it will fail -- as the class has been changed.

Unfortunately, it may too sensitive. So they allow the programmer to create the checksum. If you add a variable "serialVersionUID", it will use that as the checksum, instead of calculating it.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: serial