To get a Class object we use MyClass.class-It seems “class” is a static member of “MyClass”
Is “class” is static member of “MyClass” ?
If so when is it added and who add this field ?
Despite the similar syntax, class
is not a static member of each class. The expression C.class
is called a class literal and is a special syntax that is understood by the compiler.
It's defined in the specification:
A class literal is an expression consisting of the name of a class, interface, array, or primitive type, or the pseudo-type
void
, followed by a'.'
and the tokenclass
.
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