본문 바로가기

programming

HashTable

HashTable 사용법
1. Hashtable 생성
Hashtable<K, V> ht = new Hashtable<K, V>()
Hashtable<K, V> ht = new Hashtable<K, V>(int capacity);
Hashtable<K, V> ht = new Hashtable<K, V>(int capacity, float loadFactor);
Hashtable<K, V> ht = new Hashtable<K, V>(map t);

2. 값 추가
ht.put(0, "test0");
ht.put(1, "test1");

3. 값 삭제
ht.remove(2);//2번 키를 가지는 데이터 삭제

4. 값 변경
ht.replace(0, "test00");

5. 값 가져오기
ht.get(key);

6. 크기 구하기
ht.size();

7. 검색
ht.containsKey(key);
ht.containsValue(value);

8. 전체 key 확인하기
ht.keySet();

'programming' 카테고리의 다른 글

[파일 시스템] 파일 삭제 코드  (0) 2023.02.08
thread 동기화 방법  (0) 2022.01.22
SOLID  (0) 2022.01.17
HashSet  (0) 2021.06.24