在进行数据类型转换时,可能会遇到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);

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-27
  • 2021-11-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-12
  • 2021-10-13
  • 2021-12-31
  • 2022-12-23
  • 2021-07-09
  • 2022-12-23
相关资源
相似解决方案