例子
以下示例显示java.io.ObjectStreamClass.toString()方法的用法。
package com.jc2182;
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());
}
}
让我们编译并运行以上程序,这将产生以下结果-
java.lang.Integer: static final long serialVersionUID = 1360826667806852920L;
java.util.Calendar: static final long serialVersionUID = -1807547505821590642L;