import java.util.*;
class MyComp implements Comparator
{
public int compare(Object o1 ,Object o2)
{
Temp t1 = (Temp)o1;
Temp t2 = (Temp)o2;
if(t1.salary>t2.salary)
return 1;
elseif(t1.salary<t2.salary)
return -1;
else
return 0;
}
public static void main(String...s)
{
Comparator m = new MyComp();
TreeSet ts = new TreeSet(m);
ts.add(new Temp(10));
ts.add(new Temp(20));
ts.add(new Temp(30));
Iterator i = ts.iterator();
while(i.hasNext())
{
Temp t = (Temp)i.next();
System.out.println(t.salary);
}
}
}
class Temp
{
int salary;
Temp(int salary)
{
this.salary = salary;
}
}