Java中List与Set相互转化
在进行数据类型转换时,可能会遇到List与Set的相互转化,可行的方式有如下示例:
// List转Set List<String> tmpList = new ArrayList<>(); Set<String> tmpSet = new HashSet<>(tmpList); // Set转List Set<String> tmpSet = new HashSet<>(); List<String> tmpList = new ArrayList<>(tmpSet);
阅读是一种修养,分享是一种美德。