Java in three ways Class Gets the Class object of the class

1, with Class Class Name: the class name to the class Class static methods as a string forName

    Class c = Class.forName("com.etoak.mssm.emp.entity.Emp");


2, the class bytecode to obtain the .class file object (of any data type are provided with a static class property)
  

 Class c = User.class;

3, by getObject Object class () method
   

User user = new User();
Class c = user.getClass();
Published 49 original articles · won praise 19 · views 30000 +

Guess you like

Origin blog.csdn.net/shenju2011/article/details/103475964