package com.wuming.reflection; //什么叫反射 public class Test02 extends Object{//Object定义了一个方法被所有子类继承,就是public final Class getClass(),返回值类型是Class类//反射:就是通过对象获取类的名称public static void main(String[] args) throws ClassNotFoundException {//反射获取类的class对象Class c1 = Class.forName("com.wuming.reflection.User");System.out.println(c1);//一个类在内存中只有一个class对象,例如User//一个类被加载后,类的整个结构都会被封装在class对象中Class c2 = Class.forName("com.wuming.reflection.User");Class c3 = Class.forName("com.wuming.reflection.User");Class c4 = Class.forName("com.wuming.reflection.User");Class c5 = Class.forName("com.wuming.reflection.User");System.out.println(c2.hashCode());//hashcode相同System.out.println(c3.hashCode());System.out.println(c4.hashCode());System.out.println(c5.hashCode());} } //实体类:pojo.entity class User{private String name;private int id;private int age;public User(String name, int id, int age) {this.name = name;this.id = id;this.age = age;}public User() {}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getId() {return id;}public void setId(int id) {this.id = id;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}@Overridepublic String toString() {return "User{" +"name='" + name + '\'' +", id=" + id +", age=" + age +'}';} }=================