Java
자바의 자료구조- Map,HashMap
Ms.Pudding
2022. 1. 7. 22:32
Map도 자바의 자료구조 중의 하나인데 set인터페이스처럼 Map이라는 인터페이스가 있다.
Map컬렉션 중에 Key와 value으로 구성된 entry객체를 저장하는 Map.Entry라는 것이있다
더보기
heap영역{
map 컬렉션{
(키,값) = Map.Entry (키,값) = Map.Entry (키,값) = Map.Entry
}
}
Map컬렉션에서 공통으로 사용가능한 Map인터페이스의 메소드 중에
Map.Entry<K,V> ..... entrySet()이라는 함수가 있다.
Key와 Value의 쌍으로 구성된 모든 Map.Entry객체를 리턴한다는 뜻이다.
Map<String,String> hisSong = new HashMap<>();
hitSong.put("aespa","next level");
hitSong.put("alizee","j'en ai marre!");
for(Map.Entry<String,String> songs : hitSong.entrySet()){
System.out.println("키: + songs.getKey() + "값: " + songs.getValue());
}