Set 버전은 다음과 같이 모을 수 있다.
Set<String> result = stream.collect(Collectors.toSet());
어떤 집합 종류를 얻을지 제어하고 싶으면 다음과 같은 호출을 사용한다.
TreeSet<String> result
= stream.collect(Collectors.toCollection(TreeSet::new));
Set 버전은 다음과 같이 모을 수 있다.
Set<String> result = stream.collect(Collectors.toSet());
어떤 집합 종류를 얻을지 제어하고 싶으면 다음과 같은 호출을 사용한다.
TreeSet<String> result
= stream.collect(Collectors.toCollection(TreeSet::new));