반응형
1. 생성
List<String> list = Arrays.asList("a", "b", "c");
//방법1
Arrays.stream(list);
//방법2
list.stream();
//방법3
Stream.of("a", "b", "c");
2. 반환타입
- 중간연산 : return Stream;
filter(), map(), flatmap(), distinct(), sort(), peek(), limit(), skip() ..
- 최종연산 : return 특정한 type
3. collect
collect()를 구현한 collectors의 정적 메서드
- toList(), toSet(), toCollection(), toMap()
list.stream().collect(Collectors.toList());
list.stream().collect(Collectors.toSet());
list.stream().collect(Collectors.toCollection(HashSet :: new));
list.stream().collect(Collectors.toMap("key", "value"));
반응형
'Java' 카테고리의 다른 글
[Java] POI 라이브러리 엑셀 다운로드 (0) | 2022.05.18 |
---|---|
System.getProperty() 란? (0) | 2022.03.30 |
ApachePOI에 대하여 (0) | 2022.02.16 |
Java.util.Calendar에 대하여 (0) | 2022.02.04 |
Java 8 Stream 에 대하여 (0) | 2022.01.20 |