다량의 데이터 처리 작업을 돕고자 자바 8에 추가된 API
스트림
데이터 원소의 유한 혹은 무한 시퀀스
스트림 파이프라인
이 원소들로 수행하는 연산 단계를 표현하는 개념
스트림 안의 데이터 원소들은 객체 참조나 기본 타입 값임
스트림은 한번만 소비할 수 있다. 즉, 스트림의 연산 후 또 다른 연산을 하려고 하면 에러를 발생시킴
IntStream stream = IntStream.of(1, 2);
stream.forEach(x -> System.out::println(x));
// 다시 사용
stream.forEach(x -> System.out::println(x));
// java.lang.IllegalStateException: stream has already been operated upon or closed
중간 연산 (intermediate operation)
종단 연산 (terminal operation)
지연 평가 (lazy evaluation)