How can I get the serialVersionUID of a class?

How can I get the serialVersionUID of a class?

The following code can help u to obtain serialVersionUID of a class

import java.io.*;

public class jk 
{
	public static void main(String args[]) 
	{
		String s = new String(\"test\");
		Class cl = s.getClass();
		long uid = ObjectStreamClass.lookup(cl).getSerialVersionUID();
		System.out.println(uid);
	}
}



By:kapilsharma
Date:2018-06-09 00:00:00

The following code can help u to obtain serialVersionUID of a class

import java.io.*;

public class jk 
{
	public static void main(String args[]) 
	{
		String s = new String(\"test\");
		Class cl = s.getClass();
		long uid = ObjectStreamClass.lookup(cl).getSerialVersionUID();
		System.out.println(uid);
	}
}



By:kapilsharma
Date:2018-06-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher