Class类(在java.lang包中,Instances of the class Classrepresent classes and interfaces in a running Javaapplication):
在Java中,每一个class都有一个响应的Class对象。也就是说,当我们编写一个类,编译完成后,在生成的.class文件中,就会发生一个Class对象,用于示意这个类的范例信息。
要领1
应用对象挪用getClass()要领猎取该对象的Class实例;
要领2
应用Class类的静态要领forName(),用类的名字猎取一个Class实例(staticClass forName(String className) Returns the Classobject associated with the class or interface with the given stringname. );
要领3
应用.class的体式格局来猎取Class实例,关于基础数据范例的封装类,还能够采纳.TYPE来猎取相对应的基础数据范例的Class实例
在newInstance()挪用类中缺省的组织要领 ObjectnewInstance()(可在不知该类的名字的时刻,建立这个类的实例) Creates a new instance of the class represented by this Classobject.
在运行时期,假如我们要发生某个类的对象,Java虚拟机(JVM)会搜检该范例的Class对象是不是已被加载。假如没有被加载,JVM会依据类的称号找到.class文件并加载它。一旦某个范例的Class对象已被加载到内存,就能够用它来发生该范例的一切对象
以上就是class类是什么意义?的细致内容,更多请关注ki4网别的相干文章!