public static void main(String[] args) throws InstantiationException, IllegalAccessException {
Class bounded = int.class;
bounded = double.class;
bounded = Number.class;
bounded = Math.class;
Class<?> bounded1 = int.class;//总结1: Class<?>和class没有区别,只是编译是不提示警告
bounded1 = double.class;
bounded1 = Number.class;
bounded1 = Math.class;
Class<? extends Number> bounded2 = int.class;//总结2:Class<? extends T>可以和extents结合使用,可以用来限制? 的类型
bounded2 = double.class;
bounded2 = Number.class;
// bounded2 = Math.class;//error Math没有继承Number
Class<Integer> bounded3 = int.class;//总结3: Class<T>必须指定一个类型。当然也不可以和extends结合使用
Object o = int.class;//Every class has {@code Object} as a superclass.
o = double.class;
o = Number.class;
o = Math.class;
System.out.println(o == bounded);//true
System.out.println(o == bounded1);//true 总结4:Object可以实现Class Class<?> 的功能,
// 但是要指定范围时只能用Class<? extends T>
Class<?> bounded4 = ForName.class;// ForName.class也可以为 Class.forName("peng.liao.ForName");
Object o1 = bounded4.newInstance();//这里的o1是一个对象(ForName是我自定义的一个类)。
//这也算是Class Class<?>不能实现的, 非要说的话也是个区别吧
System.out.println(bounded);//class java.lang.Math
System.out.println(bounded1);//class java.lang.Math
System.out.println(bounded2);//class java.lang.Number
System.out.println(bounded3);//int (PS:int.class 等价于 Integer.TYPE)
System.out.println(bounded4);//class peng.liao.ForName
System.out.println(o);//class java.lang.Math
System.out.println(o1);//peng.liao.ForName@15db9742
}