public class Boy extends Person{
public void printValue(){
System.out.println("this is Boy!");
}
public Boy(){
super();
}
public static void main(String[] args) {
Person persion= new Person();
Boy boy= new Boy();
}
}
this is person!
this is Boy!
public Object clone() throws CloneNotSupportedException {
Person person= (Person)super.clone();
person.printValue();
return person;
}
public Object clone() throws CloneNotSupportedException {
Boy clone = (Boy) super.clone();
clone.printValue();
return clone;
}
@HotSpotIntrinsicCandidate
public native int hashCode();
public class Girl {
private final int age;
public Girl(int age) {
this.age = age;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof Girl)) {
return false;
}
Girl cc = (Girl)o;
return cc.age == age;
}
public static void main(String[] args) {
HashMap<Girl,Integer> hashMap= new HashMap<>();
hashMap.put(new Girl(20), 20);
System.out.println(hashMap.get(new Girl(20)));
}
}