Class and class keyword in Java

I am a little bit confused. Java has some reflection methods to call on Class<T> objects.
But I wonder what is the interconnection between Class<T> class and class keyword in java.

Class<T> is just class that uses to represent class itself (methods, fields, annotations) as an object, because everything in java is an object. class keyword is used on language level syntax to represent an entity.
When class loader loads class into memory permgen( I know that ther is no such memory area now) ,but to represent class as an object we need an object, so in this case Class<T> comes into play.

Am I correct ? Please explain how does it works ?

Answer

In short: in “imperative” context the property SomeClass.class is an instance of Class<SomeClass>. The type Class<SomeClass> represents the SomeClass class as an object (reflection).

Leave a Reply

Your email address will not be published. Required fields are marked *