-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap_example.java
More file actions
35 lines (28 loc) · 926 Bytes
/
Copy pathmap_example.java
File metadata and controls
35 lines (28 loc) · 926 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
31
32
33
34
35
import java.util.HashMap;
import java.util.Map;
public class map_example {
public static void main(String args[]) {
Map<Integer, String> m = new HashMap<Integer, String>();
m.put(5, "five");
for(Map.Entry mp:m.entrySet()) {
System.out.println(mp.getKey() + ": " + mp.getValue());
}
System.out.println("direct access: " + m.get(5));
Map<String, cmdlinearg> v = new HashMap<String, cmdlinearg>();
v.put("test", new cmdlinearg("t", "test func", true));
for(Map.Entry mp:v.entrySet()) {
System.out.println(mp.getKey() + ": " + mp.getValue());
}
System.out.println("direct access: " + v.get("test").description);
}
static class cmdlinearg {
public String short_name;
public String description;
public Boolean required;
cmdlinearg(String short_name, String description, Boolean req) {
this.short_name = short_name;
this.description = description;
this.required = req;
}
}
}