Java 8 Stream 불변 Collection
Java 8 Stream 불변 Collection
1. 소개
2. 메이븐 의존성
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>22.0</version>
</dependency>3. Java의 collectAndThen () 사용
@Test
public void whenUsingCollectingToImmutableList_thenSuccess() {
List<String> givenList = Arrays.asList("a", "b", "c");
List<String> result = givenList.stream()
.collect(collectingAndThen(toList(), ImmutableList::copyOf));
System.out.println(result.getClass());
}4. Guava's Collectors 사용 예제
5. Custom Collector 구축
6. 결론
Last updated