使用对象数组排序
public class TestSort {
public static void main(String[] args) {
// TODO Auto-generated method stub
String[] names ={"tom","vicky","join","alfa"};
System.out.println("排序前");
System.out.println(Arrays.toString(names));
//调用方法,进行排序
sortNames(names);
System.out.println("排序后");
System.out.println(Arrays.toString(names));
}
//声明一个排序的方法
public static void sortNames(String[] names){
Arrays.sort(names);
}
}