有点问题
import java.lang.* ;public class MyDate {
private int day;
private int month;
private int year;
public MyDate(int day, int month, int year) {
this.day = day;
this.month = month;
this.year = year;
}
public MyDate(MyDate date) {
this.day = date.day;
this.month = date.month;
this.year = date.year;
}
}
class TestMyDate
{
public static void main(String[] args)
{
MyDate day1=new MyDate(20,3,2009);
MyDate day2=new MyDate(20,3,2009);
System.out.println(day1.equals(day2));
System.out.println(day1.hashCode());
}
}
问题:day1.equals(day2)的返回值为什么是false?