package Day28ketangzuoye;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
public class DemoChars{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("请输入N个字符:");
String str=sc.next();
String[] arr=str.split(",");
// System.out.println(Arrays.toString(arr));
List list=new ArrayList();
for(int i=0;i<arr.length;i++){
list.add(arr[i]);
}
System.out.println("原序输出: "+list);
Collections.sort(list);
System.out.println("升序输出: "+list);
Collections.sort(list,new Comparator(){
@Override
public int compare(String o1, String o2) {
return o2.compareTo(o1);
}});
System.out.println("降序输出: "+list);
Collections.reverse(list);
System.out.println("反转指定列表中元素的顺序 "+list);
// Set set = new ArraySet(list);
// HashSet set=new HashSet(list);
// System.out.println("无序输出: "+set);
// 升序 Collections.sort(list) 降序 Collections.reserve(list) 随机 Collections.shuffle(list)
}
}
collections.sort
猫叔总结了 适合新手操作的副业 《淘宝虚拟产品月入2万的 6个 细分类目》的电子书 仅供参考
如果你对虚拟产品比较感兴趣,可以点击:
![](http://www.huamaodashu.com/wp-content/uploads/2021/03/Pasted-into-%E6%B7%98%E5%AE%9D%E5%8D%96%E4%BB%80%E4%B9%88%E8%99%9A%E6%8B%9F%E4%BA%A7%E5%93%81%E8%B5%9A%E9%92%B1%E6%9C%88%E5%85%A52%E4%B8%87-1024x571.png)