Stream - interface Stream
제네릭 Stream
static methods
of(T t) -> Stream<T>
of(T... values) -> Stream<T>
concat(Stream<T> a, Stream<T> b) -> Stream<T>
generate(Supplier<T>) -> Stream<T>
empty() -> Stream
Stream<Integer> -> IntStream
stream.mapToInt(Integer::valueOf) -> IntStream
stream.asIntStream() -> IntStream
IntStream -> Stream<Integer>
intStream.boxed() -> Stream<Integer>
intStream.mapToObj(T::new) -> Stream<T>
무한 Stream
- 생성 Pattern을 전달하면 무한 Stream 생성가능
- limit 메서드로 개수 조절
Stream<T>.iterate(T seed, UnaryOperator<T> f) -> Stream<T>
- 초기값 seed를 입력
- 이전의 결과값으 다음의 입력값으로 사용
0 : seed, 1 : f(seed), 2: f(f(seed)), ...
Stream<T>.generate(Supplier<T>) -> Stream<T>