-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathHashMapExample.java
More file actions
38 lines (31 loc) · 935 Bytes
/
HashMapExample.java
File metadata and controls
38 lines (31 loc) · 935 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
36
37
38
import java.util.*;
/**
* <h1>JavaEE Online Course</h1>
* <h2>Collections Framework</h2>
* <p>
* These classes represents the usage of Java
* Collection Framework as demonstrated on
* the Online Course conducted by Dimik Computing.
* Feel free to fork and try it on your own.
* </p>
*
* @author Sharif Ahmed (https://github.com/sharifahmed)
* @version 1.0
* @since 2016-07-01
*/
public class HashMapExample {
public static void main(String args[]) {
// create a hash map
Map<String, String> map = new HashMap<>();
// put elements to the map
map.put("Hello", "World");
map.put("James", "Bond");
map.put("Good", "Bye");
// print the size of the map
System.out.println("Size of map after additions: " + map.size());
// get elements
System.out.println("What is after 'Hello': " + map.get("Hello"));
// get all the values
System.out.println("All the values: " + map.values());
}
}