Conversion of List and Set in Java
(1) Convert List to set
List<Long> ids=new ArrayList<>();
HashSet<Long> set=new HashSet<>(ids);
It should be noted that when the List is converted to a Set, when there is duplicate data, the conversion will result in data loss, because the Set collection does not allow duplicate data.
(2) Set is converted to List
HashSet<Long> set=new HashSet<>();
List<Long> ids=new ArrayList<>(set);
Original link: https://blog.csdn.net/qq_33036061/article/details/103968822