[30일코딩] 딕셔너리 Dictionary
Dictionary
1. insert
2. find
3. delete
특징
- key-value pairs
- no-guaranteed order (except Treepmap)
- .size
- boolean? Boolean!
Reference type 사용! primitive type 사용불가!
Map<String, String> engSpanishDic = new HashMap<String, String>
- Map Interface
- concrete class HashMap
Map<String, Boolean> shoppingList = new HashMap<String, Boolean>
shoppingList.put("Ham", true);
shoppingList.put("Icecream", Boolean.FALSE);
사용
// Create a Map of String Keys to String Values, implemented by the HashMap class
Map<String,String> myMap = new HashMap<String,String>();
// Adds ("Hi","Bye") mapping to myMap
myMap.put("Hi", "Bye");
// Print the Value mapped to from "Hi"
System.out.println(myMap.get("Hi"));
// Replaces "Bye" mapping from "Hi" with "Bye!"
myMap.put("Hi", "Bye!");
// Print the Value mapped to from "Hi"
System.out.println(myMap.get("Hi"));