List转Set
1.
Set set =
new
HashSet(
new
ArrayList());
Set转List
1.
List list =
new
ArrayList(
new
HashSet());
数组转为List
1.
List arr = Arrays.asList(
"1"
,
"2"
,
"3"
);
2.
//或者
3.
String[] arr = {
"1"
,
"2"
};
4.
List list = Arrays.asList(arr);
数组转为Set
1.
int
[] arr = {
1
,
2
,
3
};
2.
Set set =
new
HashSet(Arrays.asList(arr));
Map的值转化为List
1.
List list =
new
ArrayList(map.values());
Map的值转化为Set
1.
Set set =
new
HashSet(map.values());
List转数组
1.
List list = Arrays.asList(
"a"
,
"b"
);
2.
String[] arr = (String[])list.toArray(
new
String[list.size()]);
联系客服