Java - Where does "class" method/field come from? -


this question has answer here:

where "class" method/field come from? don't find information in api.

code example:

public class someclass{     public static void main(string[] args){          system.out.println(someclass.class);     }     } 

output: class someclass

this "compiler magic" known class literals:

a class literal expression consisting of name of class, interface, array, or primitive type, or pseudo-type void, followed '.' , token class (jls 15.8.2)

in other words, although classes not have static member called class, compiler behaves if did, inserting references corresponding class objects necessary.


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -