3 ms·
> A Class is a proxy for the underlying representation of the type/class. IMHO, int.class is just as much a Class as Integer.class. There are two separate thin
by dpark 15y ago
> A Class is a proxy for the underlying representation of the type/class. IMHO, int.class is just as much a Class as Integer.class.
There are two separate things here: Class and class. Capital-C "Class" is a proxy for a type. Small-c "class" is a kind of type in Java. When someone asks why 'int' does not have a super class, the answer is because 'int' is not a class. It does have a corresponding Class* (which might have been more appropriated named "Type"), though. (There's also the '.class' literal which yields a Class. Again, the naming could have been better.)
* The Class returned by int.class actually does have a super class, because Class is a class. e.g.: int.class.getClass().getSuperclass() yields a Class representing Object.