which means whatever will you pass for TreeMap both the values will be equal. So each time when you pass the new element to TreeMap, it will compare the key and will found them same (Because of compare method implementation) and it will replace the existing value with new one.