使用对象数组排序

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);
}

}

posted @ 2020-10-17 20:14  邻座的怪同学  阅读(130)  评论(0编辑  收藏  举报