-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTheMap.java
More file actions
26 lines (19 loc) · 795 Bytes
/
Copy pathTheMap.java
File metadata and controls
26 lines (19 loc) · 795 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
import data.PersonModel;
import java.util.HashMap;
import java.util.Map;
public class TheMap {
public static void main(String[] args) {
Map<Integer, PersonModel> persons = new HashMap<>();
persons.put(1, new PersonModel("Survivor", 15));
persons.put(2, new PersonModel("Eye of the Tiger", 25));
persons.put(3, new PersonModel("Europe", 17));
System.out.println(persons);
System.out.println(persons.keySet());
System.out.println(persons.entrySet());
System.out.println(persons.containsKey(5));
System.out.println(persons.values());
System.out.println(persons.getOrDefault(5, new PersonModel("Dick", 12)));
System.out.println(persons.remove(3));
System.out.println(persons.size());
}
}