Gets the Class object of the three methods

1, calling getClass Object class () method to get the Class object, which is the most common method of producing Class object. E.g:

MyObject x;

Class c1 = x.getClass();

2、使用Class类的中静态forName()方法获得与字符串对应的Class对象。例如:

Class c2=Class.forName("MyObject"), MyObject必须是接口或者类的名字。

3、获取Class类型对象的第三个方法非常简单。如果T是一个Java类型,那么T.class就代表了匹配的类对象。
Published 74 original articles · won praise 0 · Views 4713

Guess you like

Origin blog.csdn.net/qq_44813090/article/details/104290413