I want to know the difference between int.class and Integer.TYPE in Java?
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);
}
}
The .class keyword get the Class object represent both primitive types and class types, while the .TYPE field of the wrapper primitive class allows you to get the Class of the primitive type which that object wraps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With