Is .class a method or field?

后端 未结 3 1195
既然无缘
既然无缘 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:20

    Its neither.
    It's a built-in language feature (a class literal) that looks like a public static final field.

提交回复
热议问题