Possible Duplicate:
Why should I bother about serialVersionUID?
I am going through some exception handling code and i saw something named as serialVersionUID. What this uid is for?? Is it only limited to exception or can be used in all classes??? what is the advantage of this id???
serialVersionUIDis a field to define the version of a particular class whileseriializing&deseriializing.. consider a scenario where you have a classEmployeewhich has 3 fields which has been in production for some time (meaning there may exist many serialized versions of employee objects), when you update the class to include (say a 4th field) then all the previous class (which are serialized) cannot be casted or de-serialized to the new one & you’ll get an exception.to avoid this issue, you can use the
serialVersionUIDfield to tellJVMthat the new class is in fact of a different version (by changing theserialVersionUID).@Farmor&@Tom Jefferyssaid pretty much the same thing, but with an example things look a lot simpler.