package zzy;
import static java.lang.System.*;
import java.util.*;
/**
*
* @author Zhu Zhengyan
*/
public class zzy9 {
public static void main(String[] args)
{
String[] m = {"zzy","zknm","lt"};
Arrays.sort(m,new LengthComparator()); //Arrays.sort可以传入一个comparator对象
out.println(Arrays.toString(m));
}
}
class LengthComparator implements Comparator<String>
{
public int compare(String a,String b)
{
return a.length()-b.length();
}
}
import static java.lang.System.*;
import java.util.*;
/**
*
* @author Zhu Zhengyan
*/
public class zzy9 {
public static void main(String[] args)
{
String[] m = {"zzy","zknm","lt"};
Arrays.sort(m,new LengthComparator()); //Arrays.sort可以传入一个comparator对象
out.println(Arrays.toString(m));
}
}
class LengthComparator implements Comparator<String>
{
public int compare(String a,String b)
{
return a.length()-b.length();
}
}