List를 Map<K, List<V>>로 바꾸기
public Map<Integer, List<String>> getMap(List<String> strings) {
return strings.stream().collect(
Collectors.groupingBy(String::length, HashMap::new, Collectors.toCollection(ArrayList::new))
);
}
'Java' 카테고리의 다른 글
[Java] getPathInfo() getRequestURI() getServletPath() 차이 (0) | 2023.02.21 |
---|---|
[JXLS] jx:if 사용법 (0) | 2022.12.15 |
[Java] 문자열을 문자 배열로, 문자 배열을 문자열로 변환 (0) | 2022.11.07 |
[Java] 문자열 대문자/소문자 전환 (0) | 2022.11.02 |
[Java] == 으로 문자열 비교가 안되는 이유 (0) | 2022.11.02 |