new Class[]{int.class}是个Class数组并不是int,int.Class指的是基本数据类型int的封装类Integer(还可以用int.TYPE来获得该封装类)
new Class[]{int.class} 为一个class数组分配空间,并且第一个元素是Int类
class 数组,进行了初始化。和int [] iarray = new int[] {1,2,3}差不多
Quincylk() i就是小写,没有大写,我确定
查了下core java卷一,确实有你这种用法! A third method for obtaining an object of type Class is a convenient shorthand. If T is any Java type, then T.class is the matching class object. For example:Class cl1 = Date.class; // if you import java.util.*; Class cl2 = int.class; Class cl3 = Double[].class;Note that a Class object really describes a type, which may or may not be a class. For example, int is not a class, but int.class is nevertheless an object of type Class.Class类是个很有用的类,用它可以实现反射机制,你要是学习spring也会碰到它! 个人水平有限,没法跟你解释的更清楚了,想多了解点就看core java(java核心技术),上面 的信息多一点!
Int是int的包装类,int是基本数据类型,而Int是类!
Class类是一个表示类的基本信息的类!new Class[]{ Int.class }的意思是:有一个专门存放类的基本属性的Class数组,
它里面初始化了一个Int.class元素!这个数组不是存你所说的int数据的!
你可以这用: new Class[]{ Int.class, Double.class, Float.class, Emplyee.class }
诸如此类的!
自己体会吧!
A third method for obtaining an object of type Class is a convenient shorthand. If T is any Java type, then T.class is the matching class object. For example:Class cl1 = Date.class; // if you import java.util.*;
Class cl2 = int.class;
Class cl3 = Double[].class;Note that a Class object really describes a type, which may or may not be a class. For example, int is not a class, but int.class is nevertheless an object of type Class.Class类是个很有用的类,用它可以实现反射机制,你要是学习spring也会碰到它!
个人水平有限,没法跟你解释的更清楚了,想多了解点就看core java(java核心技术),上面
的信息多一点!
int.class.getClass();
我总觉得他与int.class
和Class.forName
是一样的,我也
希望有人来说个明白。