You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 조건에 일치하는 첫 번째 것을 반환한다.stuStream.filter(s->s.getTotalScore() <= 100).findFirst();
// 병렬 스트림인 경우에는 findFirst 대신 findAny를 사용해야 한다.stuStream.parallel().filter(s->s.getTotalScore() <= 100).findAny();
통계
IntStream과 같은 기본형 스트림에는 스트림의 요소들에 대한 통계 정보를 얻을 수 있는 메서드들이 있다. 그러나 기본형 스트림이 아닌 경우에는 통계와 관련된 메서드들이 아래의 3개뿐이다.
// 스트림에 저장된 요소들을 T[] 타입의 배열로 변환하려면, toArray()를 사용하면 된다.// 단, 해당 타입의 생성자 참조를 매개변수로 지정해줘야 한다. 그렇지 않으면 Object[] 가 반환된다.Student[] stuNames = studentStream.toArray(Student[]::new);
Student[] stuNames = studentStream.toArray(); // 에러Object[] stuNames = studentStream.toArray();
스트림의 최종 연산
IntStream과 같은 기본형 스트림에는 스트림의 요소들에 대한 통계 정보를 얻을 수 있는 메서드들이 있다. 그러나 기본형 스트림이 아닌 경우에는 통계와 관련된 메서드들이 아래의 3개뿐이다.
스트림의 요소를 줄여나가면서 연산을 수행하고 최종결과를 반환한다. 처음 두 요소를 가지고 연산한 결과를 가지고 그 다음 요소와 연산한다.
collector
스트림 → 컬렉션
The text was updated successfully, but these errors were encountered: