Java - Where does "class" method/field come from? -
this question has answer here:
- is .class method or field? 3 answers
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
'.', tokenclass(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
Post a Comment