Home » Java programming language

Java ObjectStreamClass getSerialVersionUID() Method with Example

ObjectStreamClass Class getSerialVersionUID() method: Here, we are going to learn about the getSerialVersionUID() method of ObjectStreamClass Class with its syntax and example.
Submitted by Preeti Jain, on April 12, 2020

ObjectStreamClass Class getSerialVersionUID() method

  • getSerialVersionUID() method is available in java.io package.
  • getSerialVersionUID() method is used to get the serial version UID for this ObjectStreamClass class and the uid defines a set of classes with the same name that has evolved from a common root class and satisfies to be serialized and deserialized during a common format.
  • getSerialVersionUID() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
  • getSerialVersionUID() method does not throw an exception at the time of returning serial version UID.


    public long getSerialVersion();


  • It does not accept any parameter.

Return value:

The return type of the method is long, it returns the serial version UID of the class defined by this descriptor.


// Java program to demonstrate the example 
// of long getSerialVersion() method of 
// ObjectStreamClass

import java.io.*;
import java.util.*;

public class GetSerialVersionUID {
 public static void main(String[] args) {
  // Instantiates ObjectStreamClass for 
  // and Calendar
  ObjectStreamClass o_stm = ObjectStreamClass.lookup(Calendar.class);

  // By using getSerialVersionUID() method is to return
  // the serial version uid of this class
  long svuid = o_stm.getSerialVersionUID();

  // Display svuid
  System.out.println("o_stm.getSerialVersionUID(): " + svuid);


o_stm.getSerialVersionUID(): -1807547505821590642

Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.