public class Car {标签:java,Car,car1,System,hashCode,println,out From: https://www.cnblogs.com/Chen12138/p/16848674.html
public int age;
public static void main(String[] args) {
// 类是模板是抽象的,对象是具体的
Class<Car> carClass = Car.class;//模板反射对象
// 名字在栈里面,数据在堆里面。正因为数据都在堆里面,所以垃圾主要存在堆里面
// 栈是引用地址
Car car1 = new Car();
Car car2 = new Car();//把一个对象类实例化成一个对象
Car car3 = new Car();
System.out.println(car1.hashCode());
System.out.println(car2.hashCode());
System.out.println(car3.hashCode());
// 把实例化的对象返回到他这个类的具体的模板 --- 使用getClass
Class<? extends Car> aClass1 = car1.getClass();
Class<? extends Car> aClass2 = car1.getClass();
Class<? extends Car> aClass3 = car1.getClass();
System.out.println(aClass1.hashCode());
System.out.println(aClass2.hashCode());
System.out.println(aClass3.hashCode());
car1.age = 1;
car2.age = 2;
car3.age = 3;
}
}