728x90
반응형
이 문서는 추후 다시 볼 목적으로 정리한 글입니다.
set --> map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set<String> members = new HashSet<>(); | |
... | |
... | |
Map<String, Integer> map = members.stream() | |
.map(s -> groupName + Constants.SEPARATOR + s) | |
.collect(Collectors.toMap ( | |
s->s, s->getXxxCount(s))) | |
; |
list --> map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<객체> list; | |
Map<String,객체> map = | |
list.stream().collect(Collectors.toMap(객체::getId(), i -> i)); |
'Java > stream' 카테고리의 다른 글
java stream 예제 - String array --> map 으로 변환 (0) | 2020.07.09 |
---|---|
java stream 예제 - String 을 Split 해서 map 으로 만든다. (0) | 2020.07.09 |
java stream 예제 - map 에서 최소,최대 값 구하기. (0) | 2020.07.09 |
java stream 예제 - map 의 value 을 기반으로 string array 로 변환 (0) | 2020.07.09 |
java stream 예제 - List 안에 List 의 값에서 특정 조건을 만족하는 값을 찾는 것 (0) | 2020.07.09 |
댓글