2
What is the difference between using Integer.TYPE
and int.class
?
I did some tests and both can be passed as a parameter to a Class<?>
.
2
What is the difference between using Integer.TYPE
and int.class
?
I did some tests and both can be passed as a parameter to a Class<?>
.
2
Integer.TYPE and int.class are the same thing.
If you run the following snippet, you will see that the return is true.
System.out.println(Integer.TYPE.equals(int.class));
The definition of Integer.TYPE is as follows::
public static final Class<Integer> TYPE = (Class<Integer>) Class.getPrimitiveClass("int");
Browser other questions tagged java reflection
You are not signed in. Login or sign up in order to post.
As far as I know, it’s all the same
Class
. If I find any reference confirming this, put as answer.– mgibsonbr