What does .class mean after a class name

前端 未结 3 1317
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-25 12:03

What does .class mean in, for example, MyClass.class? I understand that when you put the name of a class and the point it is used to access its sta

3条回答
  •  [愿得一人]
    2020-12-25 12:50

    You can add .class to the name of any class to retrieve an instance of its Class object.

    When you use Integer.class you reference an instance of Class, which is a typed class object.

    I always thought this was a field member that got added by the compiler, but it looks like it's really just syntactic sugar.

提交回复
热议问题