In my code I (accidentially) wrote void.class
(not Void.class
) which was happily accepted by the compiler. Until now I thought that the primites are no real objects (not only void
, also talking about int
, etc... here), so they'd have no class.
I'm talking about all the "primitive classes". Every primitive type has a class denoted by <primitivetype>.class
, for example float.class
- What "
Class
" is referred to by such a "primitive class", e.g.void.class
? - what are the possible use cases of these "primitive classes"?
- Especially, do they offer a constructor?
- Can we make meaningful instance checks like
int.class.isInstance(2.3f)
?