Skip to content

류효정/5주차#13

Open
YEOUL0520 wants to merge 1 commit into
developfrom
yeoul4
Open

류효정/5주차#13
YEOUL0520 wants to merge 1 commit into
developfrom
yeoul4

Conversation

@YEOUL0520
Copy link
Copy Markdown
Owner

[5주차] 귤 고르기 / lv2 / .

  • HashMap을 써서 모든 tangerine 의 number에 해당하는 배열을 만들 필요 없이 존재하는 number에 해당하는 값만 매핑시킬수 있도록 함.
  • HashMap 자체적으로는 sort함수를 쓸 수 없다는 걸 알게 되었고, 람다식에 대해 공부할 수 있었다.

Comment thread Tangerine.java
List<Integer> valueList = new ArrayList<>(tangerineMap.keySet());
valueList.sort(((o1, o2) -> tangerineMap.get(o2) - tangerineMap.get(o1)));

for (int v : valueList) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반복문 사용할때 그냥 int v로 할 수도 있다는 것을 알았어용

Comment thread Tangerine.java

for (int t : tangerine)
{
tangerineMap.put (t, tangerineMap.getOrDefault(t, 0)+1);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

자바에 있는 defaultValue() 함수가 지정된 키로 매핑된 값이 없거나 null이면 반환하는 함수라고 해서 넘 신기했어욤

@YEOUL0520 YEOUL0520 deleted the branch develop February 16, 2025 12:43
@YEOUL0520 YEOUL0520 closed this Feb 16, 2025
@YEOUL0520 YEOUL0520 reopened this Feb 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants