Hashmap Implementation : Here's a simple HashMap implementation    

    `HashMap<String,String> hashMap=new HashMap<>();
        		hashMap.put(new String("ABC"), "Hello");
        		hashMap.put("ABC", "Hello");
        		System.out.println(hashMap.size());`

How does the code return size as 1 with how internally this is evaluated? However if i use StringBuffer instead of String code returns value as 2.
Is it because it internally compares the value using compareTo() method?