-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHashMapPrac.java
More file actions
30 lines (22 loc) · 927 Bytes
/
HashMapPrac.java
File metadata and controls
30 lines (22 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.util.ArrayList;
import java.util.HashMap;
public class HashMapPrac {
public static void main(String[] args) {
ArrayList<String> arrayList = new ArrayList<>();
arrayList.add("이상해꽃");
// HashMap
// Key -> Value
HashMap<String, String> pokedex = new HashMap<String, String>();
pokedex.put("피카츄","피카츄");
pokedex.put("라이츄", "라이츄");
pokedex.remove("이상해풀");
// 찾고자 하는 value에 해당하는 key를 파라미터로 넘겨준다.
String poke003 = pokedex.get("이상해꽃");
System.out.println(poke003);
// 같은 key에 여러 value를 저장하면 가장 마지막에 저장된 value로 덮어씌워진다.
pokedex.put("피카츄", "피카츄3");
for (String key:pokedex.keySet()) {
System.out.println(key + pokedex);
}
}
}