| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- AWS
- MySQL
- 파이썬
- 리액트
- docker
- 리팩토링
- github
- 자바
- machine-learning
- Java
- 도커
- kubernetes
- DataGridView
- git
- Spring
- Kotlin
- design pattern
- mybatis
- springboot
- Winform
- 코틀린
- 스프링
- react
- Python
- 쿠버네티스
- Spring Boot
- 스프링부트
- 마이바티스
- VOA
- c#
Archives
- Today
- Total
보뇨 다이어리
Stream.takeWhile 과 Stream.filter 차이 본문
반응형
인터넷에 치면 바로 내용이 나오긴하지만 기억해둘겸 적어봅니다
바로 아래의 코드를 일단 보도록하면..
Stream.of(1,2,3,4,5,6,7,8,9)
.filter(n -> n%2 == 0)
.forEach(System.out::println);
Stream.of(2,4,3,4,5,6,7,8,9)
.takeWhile(n -> n%2 == 0)
.forEach(System.out::println);
filter는 조건에 대해 다 검사하며 참인것만 다음으로 넘어가지만 takeWhile은 조건에 대해 참이 아닐경우 바로 거기서 멈추게 된다 즉 결과는 이런식으로 나오게 된다.
2
4
6
8
2
4반응형
'컴퓨터 관련 > Java 정보' 카테고리의 다른 글
| webflux R2DBC 빈 에러 (0) | 2021.09.14 |
|---|---|
| Spring Context 에 있는 Bean 으로 static field 주입 (0) | 2021.04.24 |
| Creation of SecureRandom instance for session ID generation using 에러 (0) | 2019.08.19 |
| Attempt to recreate a file for type 에러 (2) | 2019.07.29 |
| Unsatisfied dependency expressed through field 'restTemplate' 에러 (0) | 2019.07.25 |