Java.io.ObjectStreamClass.lookupAny() Method

Advertisements


Description

The java.io.ObjectStreamClass.toString() method returns a string describing this ObjectStreamClass.

Declaration

Following is the declaration for java.io.ObjectStreamClass.toString() method

public String toString()

Parameters

  • NA

Return Value

This method returns a string representation of the object.

Exception

  • NA

Example

The following example shows the usage of java.io.ObjectStreamClass.toString() method.

package com.tutorialspoint;

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

public class ObjectStreamClassDemo {

   public static void main(String[] args) {

      // create a new object stream class for Integers
      ObjectStreamClass osc = ObjectStreamClass.lookupAny(Integer.class);

      // print the object as a string
      System.out.println("" + osc.toString());

      // create a new object stream class for Calendars
      ObjectStreamClass osc2 = ObjectStreamClass.lookup(Calendar.class);

      // print the object as a string
      System.out.println("" + osc2.toString());
   }
}

Let us compile and run the above program, this will produce the following result:

java.lang.Integer: static final long serialVersionUID = 1360826667806852920L;
java.util.Calendar: static final long serialVersionUID = -1807547505821590642L;



Advertisements
Advertisements