자바의 자료구조 Map (HashMap, TreeMap, HashTable, LinkedHash Map)
Map은 'Key' 'Value'를 동시에 넣는 배열입니다. 즉, 'Key'를 통해 데이터를 가져옵니다. Map을 정의할 때, HashMap map이름=new HashMap();의 형태로 정의하는데 HashMap 이외 HashTable, TreeMap, LinkedhasMap으로 정의가 가능합니다. 우선 예제를 통해 Map을 어떻게 사용하는지 알아보도록 해요. HashMap HashMap map = new HashMap(); map.put(1, "가나다"); map.put(2, "라마바"); System.out.println(map.get(1)); map.put(key,value);의 구조로 정의합니다. 'key' 또는 'value' 데이터를 넣지 않으면 형태에 맞지 않기 때문에 에러가 발생돼요. 정의 ..
2021. 3. 22.