类对象:所有的类都存在一个类对象,类对象用来描述这种类都有什么属性和方法
获取类对象三种方法:
Class cla =Class.forName("com.gh.model.Person"); //com.gh.model 为包名 Person 类名
Class cla1 = Person.class;
Class cla2 = new Person().getClass(); //案例中Person无参构造被私有化
获取类对象三种方法:
Class cla =Class.forName("com.gh.model.Person"); //com.gh.model 为包名 Person 类名
Class cla1 = Person.class;
Class cla2 = new Person().getClass(); //案例中Person无参构造被私有化
相关文章: