How does a '.class' property work?

后端 未结 5 931
孤城傲影
孤城傲影 2020-12-06 09:54

First time developing in Java, and first time developing for Android, so it\'s quite a newbie question.

I currently have this code:

public void onBt         


        
5条回答
  •  南方客
    南方客 (楼主)
    2020-12-06 10:24

    Instances of the class where Class represent classes and interfaces in a running Java application. This is part of java Reflection API. From Oracle tutorial:

    If the type is available but there is no instance then it is possible to obtain a Class by appending ".class" to the name of the type. This is also the easiest way to obtain the Class for a primitive type.

    Here are some references:

    1. https://docs.oracle.com/javase/tutorial/reflect/class/classNew.html
    2. https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html

提交回复
热议问题