TreeMap1 HashMap | 값 가져오기 | 정렬하기 | TreeMap | etc HashMap의 특징 Key : Value 로 이루어진 자료형. Key는 고유한 값으로 중복이 허용되지 않는다. value는 중복이 가능하다. 순서가 없는 자료 구조. 메소드들 HashMap map = new HashMap(); map.put(1, "jina"); map.put(2, "dana"); map.put(3, "alex"); [ 키와 값을 같이 가져오는 entrySet() ] 키와 값을 같이 가져와야하는 경우, Map.Entry 인터페이스의 entrySet() 메서드를 사용한다. Map 객체의 키와 값을 접근할 수 있도록 해주는 getKey(), getValue() 함수가 존재한다. 방법 1: for문 for( Map.Entry pair : map.entrySet() ){ System.out.p.. 2024. 2. 13. 이전 1 다음