Page 626 of
SCJP J5 Study Guide (Sierra), I found the following to be irrational associated to the
testing of HashMaps...
import java.util.*;
class MapEQ {
public static void main(
String [] args) {
Map<ToDos, String> m = new HashMap<ToDos, String>();
String monday=new String("Monday");
ToDos t1=new ToDos(monday);
ToDos t2=new ToDos("Monday");
ToDos t3=new ToDos("Tuesday");
m.put(t1, "doLaundry");
m.put(t2, "payBills");
m.put(t3, "cleanAttic");
System.out.println(m.size());
}
}
will deliver different results. Knowing how Strings are handled is a requirement for the exam - equals() vs. == .