728x90 반응형 Stream1 [Java8] 중복 데이터 제거를 위한 Stream distinct 중복 데이터를 제거하기 위해 Stream distinct를 사용합니다. 동일한 객체의 판단하는 기준은 Object.equals(Object)의 결과 값이다. String 객체의 경우 equals()가 이미 구현되어 있습니다. - Stream.distinct() : Returns a stream consisting of the distinct elements (according to Object.equals(Object)) of this stream. List strings = Arrays.asList("hello", "world", "hello", "java", "hello"); strings.stream().distinct().forEach(System.out::println); // "hello".. 2020. 10. 31. 이전 1 다음 728x90 반응형