Collectors.toSet() and HashSet

前端 未结 1 1513
轻奢々
轻奢々 2021-01-30 19:34

Take the following line of sample code:

Set someSet = someColletion.stream().map(p -> p.toString()).collect(Collectors.toSet());
相关标签:
1条回答
  • 2021-01-30 20:18

    If you want a guaranteed HashSet, use Collectors.toCollection(HashSet::new).

    0 讨论(0)
提交回复
热议问题