My simple java code looks like below:
String s1 = "FB";
String s2 = "Ea";
System.out.println(s1.hashCode() == s2.hashCode()); // true
Map<String, Integer> map = new HashMap<>();
map.put(s1, 1);
map.put(s2, 2);
While debugging this piece of code in IntelliJIdea, I am not able see the linked list created by HashMap data structure, also, it is creating two buckets instead of one though hashcode is same for s1
and s2
. Could you please provide clarity on this?