Java Study Notes 12, java Study Notes
The Object class is the parent class of all classes, arrays, and enumeration classes. It is the root class of the class hierarchy. Each class uses an Object as a superclass. All objects (including
Array.
The Object class implements the following methods:
Let's take a look at the getClass () method in the source code:
public final native Class<?> getClass();
The above Class <?> The getClass () method returns the runtime class of the object.
For specific usage, see the following procedure:
class Work{}public class Main {public static void main(String[] args) {Class clazz1="Class".getClass();System.out.println(clazz1);Class clazz2=new Integer("123").getClass();System.out.println(clazz2);Class clazz3=new Work().getClass();System.out.println(clazz3);}}
Output result:
Class java. lang. String
Class java. lang. Integer
Class code2.Work
After obtaining the Class object corresponding to a Class, we can call the Class Object method to obtain the real information of the object and the Class. About
The usage of Class will be introduced later when it comes to reflection.
Reprinted please indicate the source: http://blog.csdn.net/hai_qing_xu_kong/article/details/43899035 sentiment control _