Posts

Showing posts from August, 2014

Why serialVersionUID Is Required??

Image
   serialVersionUID is used to identify the class during deserialization process.if you don't mention serialVersionUID in your class then  by default JVM will generate it . JVM generated  serialVersionUID will be a 64 bit hash value of class name ,method and fields.But there is a problem in not declaring serialVersionUID manually. Let me explain it with the example ,   This is my class which i want to serialize public class Employee implements Serializable {         /**      *      */     public int getEmpId() {         return empId;     }     public void setEmpId(int empId) {         this.empId = empId;     }     public String getEmpName() {         return empName;     }     public void setEmpName(String empName) {         this.empName = empName;     }     private int empId;     transient private String empName; } In the above code i didn't  declare serialVersionUID. Below code used to serialize the Employee object public class Serializ