인프런 커뮤니티 질문&답변
문제 4번 관련 질문입니다.
작성
·
213
0
public class ItemPriceTest {
  public static void main(String[] args) {
    Map<String, Integer> map = new HashMap<>();
    map.put("사과", 500);
    map.put("바나나", 500);
    map.put("망고", 1000);
    map.put("딸기", 1000);
    // 코드 작성
    ArrayList<String> list = new ArrayList<>();
    for (Map.Entry<String, Integer> entry : map.entrySet()) {
      if (entry.getValue().equals(1000)) {
        list.add(entry.getKey());
      }
    }
    System.out.println(list);
  }
}
여기서 entry.getValue() 의 비교를 == 으로 바꿔도 돌아가는데 상관없을까요? 객체의 경우 == 이냐, equals냐에 따라 동일성, 동등성 비교로 나뉘는거같은데 이와같이 값 비교 할 땐 둘 다 사용할 수 있는걸까요? == 을 사용해도 망고, 딸기가 출력되어 여쭤봅니다 
[질문 내용]
여기에 질문 내용을 남겨주세요.






답변 감사합니다!