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());
}
'Java' 카테고리의 다른 글
오버라이딩 vs 오버로딩 (0) | 2022.01.08 |
---|---|
abstract 클라스, 추상클라스 vs 인터페이스 (0) | 2022.01.08 |
자바의 자료구조-Set,HashSet 개념 및 사용법 (0) | 2022.01.07 |
Stringbuffer 클래스 (0) | 2022.01.07 |
인스턴스 변수, 클래스 변수 , static변수 (0) | 2022.01.07 |
댓글