Is .class a method or field?

后端 未结 3 1188
既然无缘
既然无缘 2020-12-05 07:36

Any class in the java has a .class , I want to know .class is a static method or not? Or it is a public static field?

boolean alwaysTrue = (String.class == C         


        
3条回答
  •  抹茶落季
    2020-12-05 08:00

    https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.8.2

    It's neither. It's an expression evaluated at compile time to the Class object for that class.

提交回复
热议问题