List<String> list = new ArrayList<String>(); list.add("China"); list.add("Switzerland"); list.add("Italy"); list.add("France"); String [] countries = list.toArray(new String[list.size()]);
String[] countries = {"China", "Switzerland", "Italy", "France"}; List list = Arrays.asList(countries);
List<Value> list = new ArrayList<Value>(map.values());
String [] countries = {"India", "Switzerland", "Italy"}; Set<String> set = new HashSet<String>(Arrays.asList(countries)); System.out.println(set);
Map<Integer, String> sourceMap = createMap(); Set<String> targetSet = new HashSet<>(sourceMap.values());
java中List、Array、Map、Set等集合相互转换的最佳方法
原文地址:http://blog.csdn.net/suifeng3051/article/details/41699033