-
[30일코딩] 딕셔너리 Dictionary개발입문/JAVA 2017. 5. 6. 16:59
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"));
'개발입문 > JAVA' 카테고리의 다른 글
[30일코딩] Binary Numbers 2진법 (0) 2017.05.06 [30일코딩] Recursion (0) 2017.05.06 [30일코딩] 배열 (0) 2017.05.06 [30일코딩] 반복문 (0) 2017.05.05 [30일코딩] 클래스와 인스턴스 (0) 2017.05.05