import java.util.*;
class demo
{
public static void main(String[] args)
{
TreeSet ts =new TreeSet(new SLC());
ts.add("abcd");
ts.add("c");
ts.add("acb");
ts.add("ddj");
System.out.println("m");
Iterator it=ts.iterator();
while(it.hasNext())
{
System.out.println(it.next());
}
}
}
class SLC implements Comparator
{
public int compare(Object o1,Object o2)
{
String s1=(String)o1;
String s2=(String)o2;
System.out.println("s");
if(s1.length()>s2.length())
return 1;
if(s1.length()==s2.length())
return 0;
return -1;
}
}
|
|