일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 마이바티스
- Spring Boot
- git
- 자바
- Java
- machine-learning
- 파이썬
- 코틀린
- 스프링
- 도커
- docker
- 리팩토링
- MySQL
- Python
- DataGridView
- Winform
- kubernetes
- 리액트
- c#
- VOA
- react
- 쿠버네티스
- Kotlin
- AWS
- 스프링부트
- github
- mybatis
- design pattern
- springboot
- Spring
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 |