Integer.class和Integer.TYPE之间的区别
这两者有什么区别?原始类型不能有类,可以 - 它是原始的。没有对象可以上课。
What is the difference between these two? A primitive type cannot have "Class", can it - it is primitive. There are no objects to have a class.
这两者有何区别?
我不是肯定你的意思,但是 - Class
对象是一个类型的运行时代表。也就是说,有一个 int.class
这样的东西与 Integer.class
不同,即使 int
不是一个类。它有点复杂,但有必要使反射工作甚至在采用原始参数或返回原始值的方法上,或者区分接受 Integer
的方法与接受 int
。
I'm not positive what you mean, but -- A Class
object is a runtime representative of a type. That said, there is such a thing as int.class
that is distinct from Integer.class
, even though int
is not a class. It's kind of complicated, but it's necessary to make reflection work even on methods that take primitive arguments or return primitive values, or to distinguish a method that accepts an Integer
from a method that accepts an int
.
Integer.TYPE
,I相信,相当于 int.class
。