What does the return value inside the Comparator actually mean?
For example :
class TreeSetDemo
{
public static void main(String
the way comparator is leveraged here is wrong but for clarifying your doubt why only [20] id being written when return value is 0...
You are using a TreeSet which doesn't hold identical values(Property of Set). So when the values are compared and return value is zero, Java treats them as equal and retain only the first value. Hence, you are seeing only one value in return.