例子
以下示例显示java.io.ObjectStreamClass.getName()方法的用法。
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.lookup(Integer.class);
// get the name of the class and print it
System.out.println("" + osc.getName());
// create a new object stream class for Calendar
ObjectStreamClass osc2 = ObjectStreamClass.lookup(Calendar.class);
// get the name of the class and print it
System.out.println("" + osc2.getName());
}
}
让我们编译并运行以上程序,这将产生以下结果-
java.lang.Integer
java.util.Calendar