标签:word logs ash 技术分享 font image result span strong
1、数组转List:
String[] countries = {"Array", "List", "Set", "Map"};
List list = Arrays.asList(countries);
2、Array转:Set
String [] countries = {"Array", "List", "Set"};
Set<String> set = new HashSet<String>(Arrays.asList(countries));
System.out.println(set);
3、List转Array:
List<String> list = new ArrayList<String>();
list.add("Array");
list.add("List");
list.add("Set");
list.add("Map");
String [] countries = list.toArray(new String[list.size()]);
4、Map转List:
List<Value> list = new ArrayList<Value>(map.values());
5、Map转Set:
Map<Integer, String> map = createMap();
Set<String> set = new HashSet<>(sourceMap.values());
6、List转Set:
String[] staffs
=
new String[]{"Array", "List", "Set"};
List staffsList = Arrays.asList(staffs);
Set result = new HashSet(staffsList);
java中如何实现数组、List、Set、Map之间互相转换。
标签:word logs ash 技术分享 font image result span strong
原文地址:http://www.cnblogs.com/javacatalina/p/6637549.html