stream distinct는 중복을 제거하는 공통 메소드이다. java 8 이상에서만 사용 가능
List<String> fruitList = Arrays.asList("사과", "배", "바나나", "자두", "딸기", "사과");
fruitList.stream().forEach(System.out::println);
System.out.println(" ------- distinct --------- ");
fruitList.stream().distinct().forEach(System.out::println);
새로운 변수에 저장하여 사용하자
List<String> result = fruitList.stream().distinct().collect(Collectors.toList());
사과
배
바나나
자두
딸기
사과
------- distinct ---------
사과
배
바나나
자두
딸기
[Java][Websocket] org.springframework.beans.factory.BeanCreationException 에러 (0) | 2015.11.23 |
---|---|
[JAVA/JSP] 현재시간 구하기 (0) | 2015.11.23 |
댓글 영역