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

service - Android MediaPlayer calls onCompletion before it already finished -

javascript - Training Neural Network to play flappy bird with genetic algorithm - Why can't it learn? -

javascript - Create a stacked percentage column -