Arrays.asList()

1.数组--->List

String[]  ss={"abc","def","xyz","aaaaaaaa","bbbb","abc"};
List<String> list=new ArrayList<String>(Arrays.asList(ss));//按添加顺序显示
System.out.println("list---->"+list); //list---->[abc, def, xyz, aaaaaaaa, bbbb, abc]

2.数组--->Set

String[]  ss={"abc","def","xyz","aaaaaaaa","bbbb","abc"};
Set<String>set=new TreeSet<String>(Arrays.asList(ss));;//TreeSet有排序去重功能
System.out.println("set---->"+set); //set---->[aaaaaaaa, abc, bbbb, def, xyz]
上一篇:k8s+Jenkins+GitLab-自动化部署项目


下一篇:[Tomcat 源码分析系列] (二) : Tomcat 启动脚本-catalina.bat