得到实例对象字节码的三种方式,不错,讲的挺好的 ,正好用到
public static void main(String[] args) throws Exception {
String str = "abc";
Class cls1 = str.getClass();
Class cls2 = String.class;
Class cls3 = Class.forName("java.lang.String");
System.out.println(cls1 == cls2);
System.out.println(cls2 == cls3);
}
true
true |
|