Home » Java programming language

Java ObjectStreamClass lookup() Method with Example

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

ObjectStreamClass Class lookup() method

  • lookup() method is available in java.io package.
  • lookup() method is used to lookup the descriptor for a class that can be serialized.
  • lookup() method is a static method, it is accessible with the class name and if we try to access the method with the class object then we will not get any error.
  • lookup() method does not throw an exception at the time of lookup descriptor.


    public static ObjectStreamClass lookup(Class c);


  • Class c – represents the class for which to lookup the descriptor.

Return value:

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


// Java program to demonstrate the example 
// of ObjectStreamClass lookup(Class c) method 
// of ObjectStreamClass

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

public class LookUp {
 public static void main(String[] args) {
  // Instantiates ObjectStreamClass for 
  // and Calendar 

  // By using lookup() method is to find the 
  // descriptor for the class must implements
  // Serializable interface
  ObjectStreamClass o_stm = ObjectStreamClass.lookup(Calendar.class);

  // By using getName() method is to
  // return the name for the class
  String name = o_stm.getName();

  // Display name
  System.out.println("o_stm.getName(): " + name);


o_stm.getName(): java.util.Calendar

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.