在进行数据类型转换时,可能会遇到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);
在进行数据类型转换时,可能会遇到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);
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。