欢迎光临小站,愿能为您提供帮助与启发,热爱分享、享受分享、乐于分享,让我们携手共同进步。
List、Set互转
// List转Set
Set<String> set = new HashSet<>(list);
System.out.println("set: " + set);
// Set转List
List<String> list_1 = new ArrayList<>(set);
System.out.println("list_1: " + list_1);
Array、Set互转
// array转set
s = new String[]{"A", "B", "C", "D","E"};
set = new HashSet<>(Arrays.asList(s));
System.out.println("set: " + set);
// set转array
dest = set.toArray(new String[0]);
System.out.println("dest: " + Arrays.toString(dest));