更新时间:2023-02-22 12:35:01
您可以使用 TreeSet
与自定义 Comparator
:
Comparator
构建 TreeSet
,实现您想要的自定义逻辑set.addAll(bookList)
TreeSet
with a Comparator
implementing the custom logic you wantset.addAll(bookList)
现在 Set
只包含独特的书籍.
Now the Set
contains only unique books.