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]


你可能感兴趣的:(Arrays.asList())