- class StrLenComparator implements Comparator
- {
- public int compare(Object o1,Object o2)
- {
- String s1 = (String)o1;
- String s2 = (String)o2;
- int num = new Integer(s1.length()).compareTo(new Integer(s2.length()));
- if (num ==0)
- {
- return s1.compareTO(s2);
-
- }
-
- return num;
- }
- }
复制代码 |