Integer.class与int.class [英] Integer.class vs int.class
问题描述
Integer.class
, Integer.TYPE
和 int之间有什么区别? class
?
acc to me
acc to me
-
Integer.class
是Integer(Wrapper)类对象的引用 - 但是
int.class
asint
不是类,它是原始类型。什么Integer.TYPE
是指?
Integer.class
is a reference of Integer (Wrapper) Class object- but what is then
int.class
asint
is not a class, it's a primitive type. And what doesInteger.TYPE
refer to?
推荐答案
From java.lang.Class.isPrimitive
API
From java.lang.Class.isPrimitive
API
有九个预定义的Class对象来表示八种原始类型和无效。它们由Java虚拟机创建,并且与它们表示的基本类型具有相同的名称,即boolean,byte,char,short,int,long,float和double。
There are nine predefined Class objects to represent the eight primitive types and void. These are created by the Java Virtual Machine, and have the same names as the primitive types that they represent, namely boolean, byte, char, short, int, long, float, and double.
这些对象只能通过以下公共静态最终变量访问 java.lang.Boolean.TYPE
, java.lang.Integer.TYPE
etc
These objects may only be accessed via the following public static final variables java.lang.Boolean.TYPE
, java.lang.Integer.TYPE
etc
这篇关于Integer.class与int.class的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!