-
[TIL] 자료구조5 - 해시테이블 사용하기TIL 2024. 10. 5. 21:08
자바 해시테이블 메서드 정리하기
HashMap<String, Integer> map = new HashMap<>(); //해시테이블 생성 map.put("Apple", 10); // "Apple" key에 10 추가 (추가, 수정 모두 가능) map.put("Apple", 20); // "Apple" key의 value을 20으로 수정 map.put("Apple", 30); // "Apple" key의 value을 30으로 수정 map.remove("Apple"); // "Apple" key와 그에 해당하는 value을 제거 Integer value = map.get("Banana"); // "Banana" key에 해당하는 value 검색 map.containsKey(key) //특정키가 존재하는 지 확인
'TIL' 카테고리의 다른 글
[TIL] java 우선순위큐 (0) 2024.09.20 [TIL] java 문자열 다루는 메서드 정리 (1) 2024.09.18 [TIL] 쿼리스트링 에러 (1) 2024.08.28 오버라이딩, 오버로딩 (0) 2024.07.02 [TIL] 자료구조 - 배열, 연속리스트, 연결리스트 차이 (0) 2024.06.26