数组转为Set或List

String[] strs = {"ace", "boom", "crew", "dog", "eon";

Set<String> set= new HashSet<String>();
Collections.addAll(set, strs );

 

转为list也可以用上面方法,同时还可以用

List<String> list= Arrays.asList(strs);

 

参考:http://www.chahushequ.com/read.bbscs?action=topic&id=402882463a61dbf0013a621cee1e0009&bid=92&fcpage=1&fcaction=index&tagId=0

你可能感兴趣的:(list)