public class thiss {
public static void main(String[] args) {
Dogy dog1 = new Dogy("JACK", 3);
System.out.println("dog1的哈希值=" + dog1.hashCode());
dog1.info();
Dogy dog2 = new Dogy("TERRY", 2);
System.out.println("dog2的哈希值=" + dog2.hashCode());
dog2.info();
Ted t11 = new Ted();
t11.f2();
Ted t22 = new Ted();
}
}
class Dogy{
String name;
int age;
public Dogy(String name, int age){
this.name = name;
this.age = age;
System.out.println("this.的哈希值=" + this.hashCode());
}
public void info(){
System.out.println(name + "\t" + age + "\t");
}
}
class Ted{
public Ted(){
this("jack", 100);
System.out.println("Ted构造器被调用");
}
public Ted(String name, int age){
System.out.println("Ted有参构造器被调用");
}
public void f1(){
System.out.println("f1方法");
}
public void f2(){
System.out.println("f2方法");
f1();
this.f1();
}
}