diff options
| author | pants <niklasjo2004@gmail.com> | 2026-09-21 14:17:15 -0700 |
|---|---|---|
| committer | pants <niklasjo2004@gmail.com> | 2026-09-21 14:17:15 -0700 |
| commit | 3813621611945a0be23384c0c4d395b4c4a614ad (patch) | |
| tree | 1812fd440839272e7dd16f5635e180769a66f5f1 /java/Review.java | |
Diffstat (limited to 'java/Review.java')
| -rw-r--r-- | java/Review.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/java/Review.java b/java/Review.java new file mode 100644 index 0000000..b8376db --- /dev/null +++ b/java/Review.java @@ -0,0 +1,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 + + } +}
\ No newline at end of file |
