class A{
@Override
public int hashCode() {
return 10;
}
}
public class SampleClass {
public static void main(String[] args){
Map map = new HashMap();
map.put(new A(), "A");
map.put(new A(), "B");
System.out.println(map.size());
System.out.println(new A().hashCode());
System.out.println(new A().hashCode());
}
}
Output :-
2
10
10
Why 2???. If we are implementing hashCode method which is returning same integer. Should not the size be 1???