Stream, IntStream, LongStream, DoubleStream
public interface BaseStream<T, S extends BaseStream<T, S>> extends AutoCloseable {
...
}
public interface Stream<T> extends BaseStream<T, Stream<T>> {
...
}
public interface IntStream extends BaseStream<Integer, IntStream> {
...
}
public interface LongStream extends BaseStream<Long, LongStream> {
...
}
public interface DoubleStream extends BaseStream<Double, DoubleStream> {
...
}
IntStream stream = IntStream.range(1, 10);
String[] names = {"조상원", "홍길동", "이몽룡"};
Stream<String> stream = Arrays.stream(names);
List<String> names = Arrays.asList("조상원", "홍길동", "이몽룡");
Stream<String> stream = names.stream();
int[] array = {1, 2, 3, 4, 5, 6};
Arrays.stream(array)
.filter(value -> value % 2 == 0) // 중간 처리 메소드
.forEach(value -> System.out.println(value)); // 최종 처리 메소드
int sum = 0;
int[] array = {1, 2, 3, 4, 5, 6};
sum = Arrays.stream(array).sum(); // 최종 처리 메소드
전체 흐름
