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]


posted @ 2014-04-19 20:44  IT专业户  阅读(183)  评论(0编辑  收藏  举报