In Java, do class objects have the same heritance relations as the classes they represent?
The .class property always returns a Class object. The Class class (weird) has a generic parameter. The generic parameter types are subclasses.
Class<String> stringClass = String.class;
Class<Object> objectClass = Object.class;
And because with generics, Type<foo> is NOT a supertype of Type<subtype_of_foo> (see the Java tutorials), this means, that the answer is "No".
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