Example & Tutorial understanding programming in easy ways.

What is a Serial Version UID (serialVersionUID) and why should I use it?

SerialVersionUID is used to ensure that same class(That was used during Serialization) is loaded during Deserialization.serialVersionUID is used for version control of object.
If you have used Serialization then You might have seen serialVersionUID because whenever you implement Serializable interface your IDE will give you warning.

Serialversionuid Syntax:

ANY-ACCESS-MODIFIER static final long serialVersionUID = 42L;

serialVersionUID must be Static and final.You can assign any number to it.
Lets see an example:

import java.io.Serializable;

public class Emp implements Serializable{

private static final long serialVersionUID = 1L;

int empId;

String empName;

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;

Read More →
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!