728x90
중간 처리 메서드
-
Java - 스트림(Stream) 중간 처리 메서드의 종류와 사용 방법Language/Java 2022. 11. 30. 17:55
스트림(Stream) 중간 처리 메서드의 종류와 사용 방법 중간 처리 메서드의 종류 위 표는 중간 처리 메서드의 종류를 나타낸 것이다. 위와 같이 리턴 타입이 스트림이라면 중간 처리 메서드이다. 또한, 소속된 인터페이스가 공통이라는 의미는 Stream, IntStream, LongStream, DoubleStream에서 모두 제공된다는 뜻이다. 종류로는 필터링, 매핑, 정렬, 루핑이 있는데 하나씩 살펴보도록 하겠다. 필터링 필터링은 중간 처리 기능으로 요소를 걸러내는 역할을 한다. 필터링 메서드에는 distinct()와 filter()가 있다. 이들은 모든 스트림이 가지고 있는 공통 메서드이기도 하다. 1. distinct() distinct() 메서드는 중복을 제거하는데, Stream의 경우 Objec..