Skip to content

Collectors.toMap 실습 #47

Description

@bugoverdose

주제

스트림의 collect() 연산을 통해 Map을 만드는 연습을 해보자

선정 배경

  • collect(Collectors.groupingBy())을 사용하면 Map<T, List> 형식으로 데이터를 그룹화하여 정리할 수 있고,
  • collect(Collectors.partitioningBy()`을 사용하면 Map<Boolean, List> 형식으로 데이터를 구분하여 정리할 수 있다.
  • 그런데 각 key에 해당되는 데이터가 언제나 1가지인 경우, 굳이 리스트로 만들 필요가 없다.
  • 해당 챕터에서 설명되지 않은 toMap()을 통해 Map<T, K> 형식으로 데이터를 모아보는 연습을 해보자.

관련 챕터

  • [6장] 스트림으로 데이터 수집

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ch6about chapter 6

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions