Skip to content

Commit b01bae0

Browse files
authored
Create HashMapSize.java
1 parent 13f4380 commit b01bae0

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.zetcode;
2+
3+
import java.util.HashMap;
4+
import java.util.Map;
5+
6+
public class HashMapSize {
7+
8+
public static void main(String[] args) {
9+
10+
Map<String, String> capitals = new HashMap<>();
11+
12+
capitals.put("svk", "Bratislava");
13+
capitals.put("ger", "Berlin");
14+
capitals.put("hun", "Budapest");
15+
capitals.put("czk", "Prague");
16+
capitals.put("pol", "Warsaw");
17+
capitals.put("ita", "Rome");
18+
19+
int size = capitals.size();
20+
21+
System.out.printf("The size of the HashMap is %d%n", size);
22+
23+
capitals.remove("pol");
24+
capitals.remove("ita");
25+
26+
size = capitals.size();
27+
28+
System.out.printf("The size of the HashMap is %d%n", size);
29+
}
30+
}

0 commit comments

Comments
 (0)