Java
[java] java.util.HashMap 메소드 정리
간장공장공차장
2024. 4. 25. 13:18
반응형
1. HashMap 패키지 계층
-
- java.util.AbstractMap<K,V>
- java.util.HashMap<K,V>
- java.util.AbstractMap<K,V>
2. 구조
Class HashMap<K,V>
3. 특징
HashTable과 유사 ( 차이점 : key, value에 null 제한 없음, unsynchronized
get, put 함수에 대해 constant-time performance를 제공함
컬렉션에 대한 조회은 버킷의 용량과 key-value의 개수와 연관이 있기 때문에 반복 작업이 많을 시 크기 조정 필요
3. 메소드
put(K key, V value)
clear() //Removes all of the mappings from this map.
containsKey(Object key) //Returns true if this map contains a mapping for the specified key.
containsValue(Object value)
get(Object key) //Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
반응형