implicit SerialVersionID is used even after defining explicit ID, Why?

132 views Asked by At

Here in my class I have provided the serialVersionUID explicitly, but while using 'serialver' command in command prompt for this same class the UID is generated by the system as well. enter image description here
Could anyone please throw some light over the understanding of use for explicit and implicit SerialVersion UID?

   class Emp implements Serializable {
 private static final long serialversionUID =
                             1293488886969693L;


       int age;


 public Emp(int age)
 {
     this.age = age;
 }

 }
1

There are 1 answers

6
Jean-Baptiste Yunès On

serialver is just a tool to compute such ID on a given class. Java defines an way to compute IDs from the class definition. Defining it in the class is just a way to choose that ID. Many IDEs automatically computes its value with the use of serialver, but you can edit the value by yourself and choose any one you want.

You may read What is a serialVersionUID and why should I use it?