[course07] 01 Object class
Last updated
Last updated
SavingsAccount s = new SavingsAccount(500); System.out.println(s);
public class OrderedPair {
private double x;
private double y;
//constructors and other methods ...
/** Returns this OrderedPair in String form. */
public String toString() {
return "(" + x + "," + y + ")";
}
}
public boolean equals(Object other)
Date d1 = new Date(2021, Calendar.JANUARY, 14);
Date d2 = d1;
Date d3 = new Date(2021, Calendar.JANUARY, 14);
System.out.println(d1 == d2);
System.out.println(d1 == d3);
System.out.println(d1.equals(d2));
System.out.println(d1.equals(d3));