I couldn't understand why it's printing false when HashMap key is 2
Map<Integer, Integer> first = new HashMap<Integer, Integer>();
Map<Integer, Integer> second = new HashMap<Integer, Integer>();
first.put(1, 10);
second.put(1, 10);
first.put(2, 155);
second.put(2, 155);
for (int i = 1; i <= 2; i++) {
System.out.print("first=" + first.get(i) + "," + "second="
+ second.get(i) + " ");
System.out.println(first.get(i) == second.get(i));
}
Result
first=10,second=10 true
first=155,second=155 false