summaryrefslogtreecommitdiff
path: root/java/Review.java
blob: b8376dbbf741cae7294edcf14ff252bd2fd046e0 (plain)
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.*;

public class Review {
    // Create a Map of students in section to their favorite word/movie/song/etc
    // Then, edit and print out the Map 

    public static void main(String[] args) {
        // Create the Map (do you want it to do ordered?)
        Map<String, String> favorites = new TreeMap<>();
        // Add key/value pairs to the Map
        favorites.put("me", "キュ毛付きさぼたじ");
        favorites.put("nik", "warp star");
        favorites.put("andy", "none");
        System.out.println(favorites);
        // Delete one of the entries from the Map
        favorites.remove("andy");
        // Override one of the values
        favorites.put("boner", "balls");
        // Loop over the Map and print out all the values seperated by a comma and space
        // Before printing - hypothesize what the output will look like!
        for (String key : favorites.keySet()) {
            System.out.print(favorites.get(key) + ", ");
        }
        // two ways to do this:
        // 1st way - loop through keys then get values

        // 2nd way - loop through values
        
    }
}