我想知道Java中的int.class和Integer.TYPE之间的区别?
Absolutely nothing. If you run the following code, you will see that int.class
is the same thing as Integer.TYPE
.
public class Test {
public static void main(final String[] args) {
System.out.println(int.class == Integer.TYPE);
}
}
absolutely false check this :
public static void main(String[] args) {
System.out.println(int.class.equals(Integer.TYPE));
System.out.println(Integer.class.equals(Integer.TYPE));
}
output : true false
Boolean.TYPE == boolean.class
Byte.TYPE == byte.class
Short.TYPE == short.class
Character.TYPE == char.class
Integer.TYPE == int.class
Long.TYPE == long.class
Float.TYPE == float.class
Double.TYPE == double.class
Void.TYPE == void.class
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.