I was hoping that someone could tell me why java has java.lang.reflect.Type
, when everything already inherits from Object
?
Could someone please give an example of a case where I would need to use a Type
and not an Object
?
Object
is a base class for all java classes. Type
is just an tag interface for all classes that represent types. It was introduced in java 1.5 because prior to java 1.5 there was no classes that represent java type except java.lang.Class
. Then when generics were introduced there was a need to create some general abstraction common for Class
, generic array etc. So they defined interface Type
.
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