From d0663973a060e2f60e4a090aa885549422400200 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 21:42:40 -0700 Subject: [PATCH 01/63] Importing Arrays --- src/ArrayPractice.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index bc58c83..7e36cd4 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -1,4 +1,6 @@ + import java.util.Arrays; public class ArrayPractice { + public static void main(String[] args) { // Create an array of Strings of size 4 From 36ad3d56c81a3d7611bd3fb39dae58c655278e4e Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 21:44:02 -0700 Subject: [PATCH 02/63] Added 4 elements into the array with different String variables --- src/ArrayPractice.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index 7e36cd4..2199f43 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -3,11 +3,16 @@ public class ArrayPractice { public static void main(String[] args) { // Create an array of Strings of size 4 + String[] arr = new String[4]; // Set the value of the array at each index to be a different String // It's OK to do this one-by-one + arr[0] = "This"; + arr[1] = "is"; + arr[2] = "an"; + arr[3] = "array"; - // Get the value of the array at index 2 + // Get the value of the array at index 2' // Get the length of the array From 26785c9f55cb4022f25d9884cdd179a56a1fc075 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 21:45:36 -0700 Subject: [PATCH 03/63] Variable storing index 2 value --- src/ArrayPractice.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index 2199f43..238053b 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -12,7 +12,8 @@ public static void main(String[] args) { arr[2] = "an"; arr[3] = "array"; - // Get the value of the array at index 2' + // Get the value of the array at index 2 + String valueAtIndex2 = arr[2]; // Receiving the value at index 2 // Get the length of the array From 61e3415f5a70ec4b5c258bd6476e00d012c4f180 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 21:47:25 -0700 Subject: [PATCH 04/63] Length of array stored in int variable --- src/ArrayPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index 238053b..596ab6f 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -16,6 +16,7 @@ public static void main(String[] args) { String valueAtIndex2 = arr[2]; // Receiving the value at index 2 // Get the length of the array + int lengthOfArray = arr.length; // Length of array // Iterate over the array using a traditional for loop and print out each item From 4a3a2302736065e351a1984d84b7773976cb0a2e Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 21:48:02 -0700 Subject: [PATCH 05/63] For loop printing each array item --- src/ArrayPractice.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index 596ab6f..dcc2164 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -19,6 +19,9 @@ public static void main(String[] args) { int lengthOfArray = arr.length; // Length of array // Iterate over the array using a traditional for loop and print out each item + for(int i = 0; i < arr.length; i++){ + System.out.println(arr[i]); + } // Iterate over the array using a for-each loop and print out each item From 1da1ee292ab4cb322c816e5ff1ac6546704fc6c7 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 21:48:28 -0700 Subject: [PATCH 06/63] For each loop printing out each array item --- src/ArrayPractice.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index dcc2164..250df15 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -24,7 +24,9 @@ public static void main(String[] args) { } // Iterate over the array using a for-each loop and print out each item - + for(String item : arr){ + System.out.println(item); + } /* * Reminder! * From ca667e03779df0927c07a64bc126f3be327b990f Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 21:50:20 -0700 Subject: [PATCH 07/63] Importing Java List --- src/ListPractice.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ListPractice.java b/src/ListPractice.java index f4de8e7..91e0ce0 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -1,9 +1,11 @@ +import java.util.List; public class ListPractice { public static void main(String[] args) { // Create an empty ArrayList of Strings and assign it to a variable of type List + // Add 3 elements to the list (OK to do one-by-one) // Print the element at index 1 From c2e94ba875afef65c38d5adaf01e580e8770ac0a Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 21:51:04 -0700 Subject: [PATCH 08/63] Empty ArrayList created, also import changed to ArrayList --- src/ListPractice.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index 91e0ce0..ef9571d 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -1,10 +1,10 @@ -import java.util.List; +import java.util.ArrayList; public class ListPractice { public static void main(String[] args) { // Create an empty ArrayList of Strings and assign it to a variable of type List - + ArrayList myList = new ArrayList<>(); // Add 3 elements to the list (OK to do one-by-one) From 6238682d0a4ccbd9b7f8034a32caa8fbe953bb09 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 21:51:56 -0700 Subject: [PATCH 09/63] 3 elements added to list --- src/ListPractice.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ListPractice.java b/src/ListPractice.java index ef9571d..9f4963d 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -7,6 +7,9 @@ public static void main(String[] args) { ArrayList myList = new ArrayList<>(); // Add 3 elements to the list (OK to do one-by-one) + myList.add("First"); + myList.add("Second"); + myList.add("Third"); // Print the element at index 1 From ff618b94f21d37fc00191806f669886f769bb8e4 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 21:52:33 -0700 Subject: [PATCH 10/63] Printing index 1 of ArrayList --- src/ListPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ListPractice.java b/src/ListPractice.java index 9f4963d..fae90e1 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -12,6 +12,7 @@ public static void main(String[] args) { myList.add("Third"); // Print the element at index 1 + System.out.println(myList.get(1)); // Getting the element at index 1 // Replace the element at index 1 with a new value // (Do not insert a new value. The length of the list should not change) From a4996de4859faefaa0f1f08f1dbe03f947333ee0 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 21:55:23 -0700 Subject: [PATCH 11/63] Using set() to replace an index value --- src/ListPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ListPractice.java b/src/ListPractice.java index fae90e1..80a4068 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -16,6 +16,7 @@ public static void main(String[] args) { // Replace the element at index 1 with a new value // (Do not insert a new value. The length of the list should not change) + myList.set(1, "replaced value"); // Replacing the element at index 1 with .set() // Insert a new element at index 0 (the length of the list will change) From 6373342281e9c804626c38242625985360be0f59 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 21:56:07 -0700 Subject: [PATCH 12/63] using add() to a value to index 0, extending the arraylist length --- src/ListPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ListPractice.java b/src/ListPractice.java index 80a4068..02e853f 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -19,6 +19,7 @@ public static void main(String[] args) { myList.set(1, "replaced value"); // Replacing the element at index 1 with .set() // Insert a new element at index 0 (the length of the list will change) + myList.add(0, "new value here"); // Inserting a new element // Check whether the list contains a certain string From ed47094447c26e37016ae5ac13ad5cc55dbe65c6 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:04:58 -0700 Subject: [PATCH 13/63] Checking if a certain string exists within the list --- src/ListPractice.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ListPractice.java b/src/ListPractice.java index 02e853f..d503b0a 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -22,10 +22,13 @@ public static void main(String[] args) { myList.add(0, "new value here"); // Inserting a new element // Check whether the list contains a certain string + boolean containsString = myList.contains("First"); // Checking if the list contains "First" + System.out.println("List contains a string: " + containsString); // Iterate over the list using a traditional for-loop. // Print each index and value on a separate line + // Sort the list using the Collections library // Iterate over the list using a for-each loop From d35d8509a043753a976c1213e237689451e99034 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:09:38 -0700 Subject: [PATCH 14/63] Iterating using traditional loop, printing values and indexes on separate lines. --- src/ListPractice.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index d503b0a..cc7f8fe 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -27,7 +27,9 @@ public static void main(String[] args) { // Iterate over the list using a traditional for-loop. // Print each index and value on a separate line - + for(int i = 0; i < myList.size(); i++){ + System.out.println("Index: " + i + "\n" + "Value: " + myList.get(i)); + } // Sort the list using the Collections library From b16bbfdad9317b25c4af3982a7d9231a21d1f88b Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:10:29 -0700 Subject: [PATCH 15/63] importing collections --- src/ListPractice.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ListPractice.java b/src/ListPractice.java index cc7f8fe..54214a2 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -1,4 +1,6 @@ import java.util.ArrayList; +import java.util.Collections; + public class ListPractice { From 114092142853fc066316ecd18b368a8c7ef6afb5 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:10:44 -0700 Subject: [PATCH 16/63] Sorting the list --- src/ListPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ListPractice.java b/src/ListPractice.java index 54214a2..645fa21 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -34,6 +34,7 @@ public static void main(String[] args) { } // Sort the list using the Collections library + Collections.sort(myList); // Sorting the list // Iterate over the list using a for-each loop // Print each value on a second line From f58513c1e627dfa0ee6cdf12448bba1123d2aa6a Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:13:50 -0700 Subject: [PATCH 17/63] Using a for-each loop to iterate the list --- src/ListPractice.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ListPractice.java b/src/ListPractice.java index 645fa21..4a509e6 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -38,6 +38,9 @@ public static void main(String[] args) { // Iterate over the list using a for-each loop // Print each value on a second line + for(String item : myList){ + System.out.println(item); + } /* * Usage tip! From 66b57aef8ab055bd0b4b378f5ea32c9e365f205d Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:14:49 -0700 Subject: [PATCH 18/63] HashMap imported --- src/MapPractice.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MapPractice.java b/src/MapPractice.java index 7ebfeac..f8212de 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -1,5 +1,5 @@ - +import java.util.HashMap; public class MapPractice { public static void main(String[] args) { // Create a HashMap with String keys and Integer values and From 224868ddb75dd8e0d0980d1118f6e0a6dd933fb5 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:17:20 -0700 Subject: [PATCH 19/63] Created HashMap --- src/MapPractice.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/MapPractice.java b/src/MapPractice.java index f8212de..8a59ab1 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -1,9 +1,12 @@ import java.util.HashMap; + public class MapPractice { public static void main(String[] args) { // Create a HashMap with String keys and Integer values and // assign it to a variable of type Map + HashMap myMap = new HashMap<>(); + // Put 3 different key/value pairs in the Map // (it's OK to do this one-by-one) From 1bb096b5c6320aa35476fd6f2bc9097c64bb9313 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:21:18 -0700 Subject: [PATCH 20/63] Type variable changed to Map --- src/MapPractice.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MapPractice.java b/src/MapPractice.java index 8a59ab1..f478920 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -5,8 +5,8 @@ public class MapPractice { public static void main(String[] args) { // Create a HashMap with String keys and Integer values and // assign it to a variable of type Map - HashMap myMap = new HashMap<>(); - + Map myMap = new HashMap<>(); + // Put 3 different key/value pairs in the Map // (it's OK to do this one-by-one) From a9cb21a9b81305890f5d99ad87c016c7d60af6b6 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:21:34 -0700 Subject: [PATCH 21/63] Import Map util --- src/MapPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MapPractice.java b/src/MapPractice.java index f478920..cd9d8ff 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -1,5 +1,6 @@ import java.util.HashMap; +import java.util.Map; public class MapPractice { public static void main(String[] args) { From 033b7634fcdd79f5e900b7149e0d7e0dde8cb87d Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:22:03 -0700 Subject: [PATCH 22/63] Added 3 key pairs in the map --- src/MapPractice.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/MapPractice.java b/src/MapPractice.java index cd9d8ff..828365d 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -11,6 +11,9 @@ public static void main(String[] args) { // Put 3 different key/value pairs in the Map // (it's OK to do this one-by-one) + myMap.put("First", 1); + myMap.put("Second", 2); + myMap.put("Third", 3); // Get the value associated with a given key in the Map From 1d9343f44ba33ee379ff15f5071a5e9881cb5dd5 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:22:47 -0700 Subject: [PATCH 23/63] Stored key value into a variable --- src/MapPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MapPractice.java b/src/MapPractice.java index 828365d..c159815 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -16,6 +16,7 @@ public static void main(String[] args) { myMap.put("Third", 3); // Get the value associated with a given key in the Map + int valueForKey = myMap.get("Second"); // Getting the value for the key "Second" // Find the size (number of key/value pairs) of the Map From 0e9d90d8c1c8cebf547fcb03564801b8a32fd43f Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:23:10 -0700 Subject: [PATCH 24/63] map size stored into a variable --- src/MapPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MapPractice.java b/src/MapPractice.java index c159815..31474c6 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -19,6 +19,7 @@ public static void main(String[] args) { int valueForKey = myMap.get("Second"); // Getting the value for the key "Second" // Find the size (number of key/value pairs) of the Map + int mapSize = myMap.size(); // Size of the map // Replace the value associated with a given key (the size of the Map shoukld not change) From e6c3c5019467825fb0d51b8a5a65d1e37a8e700a Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:24:03 -0700 Subject: [PATCH 25/63] Replaced second key value --- src/MapPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MapPractice.java b/src/MapPractice.java index 31474c6..a3c8a3d 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -22,6 +22,7 @@ public static void main(String[] args) { int mapSize = myMap.size(); // Size of the map // Replace the value associated with a given key (the size of the Map shoukld not change) + myMap.put("Second", 22); // Replacing the value for the key "Second" // Check whether the Map contains a given key From e57f1a9dbb9b56b149026af3750bec67062cc582 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:27:41 -0700 Subject: [PATCH 26/63] Checking if the map contains a given key --- src/MapPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MapPractice.java b/src/MapPractice.java index a3c8a3d..366071d 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -25,6 +25,7 @@ public static void main(String[] args) { myMap.put("Second", 22); // Replacing the value for the key "Second" // Check whether the Map contains a given key + boolean containsKey = myMap.containsKey("First"); // Check whether the Map contains a given value From ad0b875dbe24d9178e8b89ef026c34151a05acaf Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:28:47 -0700 Subject: [PATCH 27/63] Checking if map contains a given value --- src/MapPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MapPractice.java b/src/MapPractice.java index 366071d..506a985 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -28,6 +28,7 @@ public static void main(String[] args) { boolean containsKey = myMap.containsKey("First"); // Check whether the Map contains a given value + boolean containsValue = myMap.containsValue(3); // Iterate over the keys of the Map, printing each key From 98666e00c70e88f92d62e6df0b12f396248fe4d4 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:30:53 -0700 Subject: [PATCH 28/63] Using keySet() to iterate through keys with a for each loop. --- src/MapPractice.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/MapPractice.java b/src/MapPractice.java index 506a985..69f1c7c 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -31,6 +31,10 @@ public static void main(String[] args) { boolean containsValue = myMap.containsValue(3); // Iterate over the keys of the Map, printing each key + for(String key : myMap.keySet()){ // using keySet() to grab all keys + System.out.println(key); + } + // Iterate over the values of the map, printing each value From 49522bb0016b480c4bd176bf17f8d2ee5e6acd69 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:31:34 -0700 Subject: [PATCH 29/63] Using values() to grab values of map, and storing them in type Integer value --- src/MapPractice.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/MapPractice.java b/src/MapPractice.java index 69f1c7c..b9d4458 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -34,9 +34,10 @@ public static void main(String[] args) { for(String key : myMap.keySet()){ // using keySet() to grab all keys System.out.println(key); } - - // Iterate over the values of the map, printing each value + for(Integer value : myMap.values()) { // using values() to grab all values, with Integer type + System.out.println(value); + } // Iterate over the entries in the map, printing each key and value From 95be99a5196912d3fc9531883a0d2758091df6fa Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:35:24 -0700 Subject: [PATCH 30/63] Iterating each entry using Map.Entry type variable for the map, and printing them. --- src/MapPractice.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/MapPractice.java b/src/MapPractice.java index b9d4458..298247a 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -40,6 +40,9 @@ public static void main(String[] args) { } // Iterate over the entries in the map, printing each key and value + for(Map.Entry entry : myMap.entrySet()) { // using entrySet() to grab all entries with Entry type. + System.out.println("Key: " + entry.getKey() + "\n" + "Value: " + entry.getValue()); + } /* * Usage tip! From 84c609808c2c28d678132b80ddf1bc6047a38e70 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:37:14 -0700 Subject: [PATCH 31/63] Negative float variable created --- src/NumberPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/NumberPractice.java b/src/NumberPractice.java index bbec2fe..5ce1f3c 100644 --- a/src/NumberPractice.java +++ b/src/NumberPractice.java @@ -1,6 +1,7 @@ public class NumberPractice { public static void main(String args[]) { // Create a float with a negative value and assign it to a variable + float negativeFloat = -3.14f; // Creating a float with a negative value // Create an int with a positive value and assign it to a variable From d0f7eba5bf4725d0f1f06c726d2eb5f7ee46d6d1 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:37:56 -0700 Subject: [PATCH 32/63] Last change: adding print lines under booleans checking for key/value. --- src/MapPractice.java | 2 ++ src/NumberPractice.java | 1 + 2 files changed, 3 insertions(+) diff --git a/src/MapPractice.java b/src/MapPractice.java index 298247a..00fa62c 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -26,9 +26,11 @@ public static void main(String[] args) { // Check whether the Map contains a given key boolean containsKey = myMap.containsKey("First"); + System.out.println("Map contains key: " + containsKey); // Check whether the Map contains a given value boolean containsValue = myMap.containsValue(3); + System.out.println("Map contains value: " + containsValue); // Iterate over the keys of the Map, printing each key for(String key : myMap.keySet()){ // using keySet() to grab all keys diff --git a/src/NumberPractice.java b/src/NumberPractice.java index 5ce1f3c..98352b5 100644 --- a/src/NumberPractice.java +++ b/src/NumberPractice.java @@ -4,6 +4,7 @@ public static void main(String args[]) { float negativeFloat = -3.14f; // Creating a float with a negative value // Create an int with a positive value and assign it to a variable + int posInt = 42; // Creating an int with a positive value // Use the modulo % operator to find the remainder when the int is divided by 3 From 754557e3c936dd16bfe44cd7bd27ad8eb570147b Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:38:44 -0700 Subject: [PATCH 33/63] Created a remainder variable with modulus --- src/NumberPractice.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/NumberPractice.java b/src/NumberPractice.java index 98352b5..180d20a 100644 --- a/src/NumberPractice.java +++ b/src/NumberPractice.java @@ -7,6 +7,8 @@ public static void main(String args[]) { int posInt = 42; // Creating an int with a positive value // Use the modulo % operator to find the remainder when the int is divided by 3 + int remainder = posInt % 3; // Remainder given 3 as the divisor + System.out.println(remainder); // printing remainder // Use the modulo % operator to determine whether the number is even // (A number is even if it has a remainder of zero when divided by 2) From 7ec4530db223a3486e914f577b9426cc462ca078 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:39:37 -0700 Subject: [PATCH 34/63] if/else statement checking for an even number. --- src/NumberPractice.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NumberPractice.java b/src/NumberPractice.java index 180d20a..6171d72 100644 --- a/src/NumberPractice.java +++ b/src/NumberPractice.java @@ -14,9 +14,15 @@ public static void main(String args[]) { // (A number is even if it has a remainder of zero when divided by 2) // Use an if-else to print "Even" if the number is even and "Odd" // if the number is odd. + if(posInt % 2 == 0){ + System.out.println("Even"); + } else { + System.out.println("Odd"); + } // Divide the number by another number using integer division + /* * Reminder! * From ac15cc72028d48b3bc93b2072e8f956f1e2bdd30 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:40:03 -0700 Subject: [PATCH 35/63] Using integer division to divide a number. --- src/NumberPractice.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NumberPractice.java b/src/NumberPractice.java index 6171d72..4e7a089 100644 --- a/src/NumberPractice.java +++ b/src/NumberPractice.java @@ -21,7 +21,7 @@ public static void main(String args[]) { } // Divide the number by another number using integer division - + int divisionResult = posInt / 5; // Integer division /* * Reminder! From ab5a884b94d9e6df5dffc0a4adaedd9d6e6bda62 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:40:15 -0700 Subject: [PATCH 36/63] Printing the result of integer division --- src/NumberPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/NumberPractice.java b/src/NumberPractice.java index 4e7a089..de86dfe 100644 --- a/src/NumberPractice.java +++ b/src/NumberPractice.java @@ -22,6 +22,7 @@ public static void main(String args[]) { // Divide the number by another number using integer division int divisionResult = posInt / 5; // Integer division + System.out.println(divisionResult); // printing result of integer division /* * Reminder! From f80a42f6efaadf49d9f7d97a2060c15800148ede Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:40:40 -0700 Subject: [PATCH 37/63] Public and private instance variables made in Person --- src/Person.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Person.java b/src/Person.java index 8ab3f95..db0b2c6 100644 --- a/src/Person.java +++ b/src/Person.java @@ -6,6 +6,8 @@ public class Person { // Declare a public String instance variable for the name of the person // Declare a private int instance variable for the age of the person + public String name; + private int age; // Create a constructor that takes the name and age of the person From 2ba46badf2ccb74d42a377a7cb6a3c92c8af53c9 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:41:16 -0700 Subject: [PATCH 38/63] Created a person constructer with String name, and int age parameters. --- src/Person.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Person.java b/src/Person.java index db0b2c6..e6066fe 100644 --- a/src/Person.java +++ b/src/Person.java @@ -12,6 +12,10 @@ public class Person { // Create a constructor that takes the name and age of the person // and assigns it to the instance variables + public Person(String name, int age){ + this.name = name; + this.age = age; + } // Create a toString method that gives the name and age of the person From 332a7ab28a224227d425789117fc48c1d9138947 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:41:52 -0700 Subject: [PATCH 39/63] toString() method created --- src/Person.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Person.java b/src/Person.java index e6066fe..3c3ff7b 100644 --- a/src/Person.java +++ b/src/Person.java @@ -19,6 +19,9 @@ public Person(String name, int age){ // Create a toString method that gives the name and age of the person + public String toString(){ + return "Name: " + name + "\n" + "Age: " + age; + } // Implement the below public instance method "birthYear" From 5bd897e8f7ac082c998da3994087f9a6837e8044 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:43:18 -0700 Subject: [PATCH 40/63] Instance method birthYear created --- src/Person.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Person.java b/src/Person.java index 3c3ff7b..3b069a2 100644 --- a/src/Person.java +++ b/src/Person.java @@ -37,6 +37,10 @@ public String toString(){ * @return The year the person was born */ // (create the instance method here) + public int birthYear(int year){ + int birthYear = year - age; + return birthYear; + } public static void main(String[] args) { From 3fa407f61f6fca40c6686fc9b590453a52d95d66 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:43:55 -0700 Subject: [PATCH 41/63] Instance of person object created --- src/Person.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Person.java b/src/Person.java index 3b069a2..0918051 100644 --- a/src/Person.java +++ b/src/Person.java @@ -45,6 +45,7 @@ public int birthYear(int year){ public static void main(String[] args) { // Create an instance of Person + Person person1 = new Person("Jaron", 19); // creating new instance of Person object // Create another instance of Person with a different name and age and // assign it to a different variable From 37d44fa657d09d5650779793e5986cfedffdc3ff Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:44:36 -0700 Subject: [PATCH 42/63] New instance of Person object --- src/Person.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Person.java b/src/Person.java index 0918051..2a8a3d5 100644 --- a/src/Person.java +++ b/src/Person.java @@ -49,6 +49,7 @@ public static void main(String[] args) { // Create another instance of Person with a different name and age and // assign it to a different variable + Person person2 = new Person("Maxwell", 10); // creating another instance of Person object // Print the first person From 381f76756623b70f85b7b4ffbed2ddbecb13c4ab Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:44:50 -0700 Subject: [PATCH 43/63] Printing person1 object --- src/Person.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Person.java b/src/Person.java index 2a8a3d5..235c039 100644 --- a/src/Person.java +++ b/src/Person.java @@ -52,6 +52,7 @@ public static void main(String[] args) { Person person2 = new Person("Maxwell", 10); // creating another instance of Person object // Print the first person + System.out.println(person1); // Print the second person From 5a92f413aa7e18444366651cb818d7c567a57d3f Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:45:03 -0700 Subject: [PATCH 44/63] Printing person2 object --- src/Person.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Person.java b/src/Person.java index 235c039..bd2b9c7 100644 --- a/src/Person.java +++ b/src/Person.java @@ -55,6 +55,7 @@ public static void main(String[] args) { System.out.println(person1); // Print the second person + System.out.println(person2); // Get the name of the first person and store it in a local variable From 13feabbd627e4e78cdb3a489c8b97922db22b1ac Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:45:24 -0700 Subject: [PATCH 45/63] Storing person1 name into a variable --- src/Person.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Person.java b/src/Person.java index bd2b9c7..389c74c 100644 --- a/src/Person.java +++ b/src/Person.java @@ -58,6 +58,7 @@ public static void main(String[] args) { System.out.println(person2); // Get the name of the first person and store it in a local variable + String name1 = person1.name; // Using the birthYear method, get the birth year of the first person // and store it in a local variable. Input the actual current year (e.g. 2025) From 6753be12f9c9eacaddc163f331c23fad2ab72150 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:46:14 -0700 Subject: [PATCH 46/63] Storing person1 birthYear into a variable --- src/Person.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Person.java b/src/Person.java index 389c74c..718636b 100644 --- a/src/Person.java +++ b/src/Person.java @@ -63,6 +63,7 @@ public static void main(String[] args) { // Using the birthYear method, get the birth year of the first person // and store it in a local variable. Input the actual current year (e.g. 2025) // as the argument. + int birthYear = person1.birthYear(2025); // In a separate statement, print the local variable holding the birth year. From 8c21edf6dd3820a4a9c1709e6969384c65225532 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:46:25 -0700 Subject: [PATCH 47/63] Printing person1 birthYear --- src/Person.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Person.java b/src/Person.java index 718636b..52d1856 100644 --- a/src/Person.java +++ b/src/Person.java @@ -66,6 +66,7 @@ public static void main(String[] args) { int birthYear = person1.birthYear(2025); // In a separate statement, print the local variable holding the birth year. + System.out.println("Birth year of " + name1 + ": " + birthYear); /** * Terminology! From cbe000e96a18aba740ff84d5b765f7bb3badfe07 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:47:01 -0700 Subject: [PATCH 48/63] Import java util HashSet --- src/SetPractice.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SetPractice.java b/src/SetPractice.java index d2fc1c9..8184be5 100644 --- a/src/SetPractice.java +++ b/src/SetPractice.java @@ -1,3 +1,5 @@ +import java.util.HashSet; + public class SetPractice { public static void main(String[] args) { // Create a HashSet of Strings and assign it to a variable of type Set From 6be387e417beeb31b7023477373a5f06d3e848e5 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:47:21 -0700 Subject: [PATCH 49/63] HashSet variable made --- src/SetPractice.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SetPractice.java b/src/SetPractice.java index 8184be5..69c39da 100644 --- a/src/SetPractice.java +++ b/src/SetPractice.java @@ -3,6 +3,8 @@ public class SetPractice { public static void main(String[] args) { // Create a HashSet of Strings and assign it to a variable of type Set + HashSet mySert = new HashSet<>(); + // Add 3 elements to the set // (It's OK to do it one-by-one) From 4e6b31721ff8658e809c3e9543bed83a9749a5bd Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:48:03 -0700 Subject: [PATCH 50/63] MySert -> MySet. Also, added 3 elements to set. --- src/SetPractice.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/SetPractice.java b/src/SetPractice.java index 69c39da..b6cc273 100644 --- a/src/SetPractice.java +++ b/src/SetPractice.java @@ -3,11 +3,14 @@ public class SetPractice { public static void main(String[] args) { // Create a HashSet of Strings and assign it to a variable of type Set - HashSet mySert = new HashSet<>(); - + HashSet mySet = new HashSet<>(); + // Add 3 elements to the set // (It's OK to do it one-by-one) + mySet.add("First"); + mySet.add("Second"); + mySet.add("Third"); // Check whether the Set contains a given String From 1d125c22c624135f5fc40c358db66731c80191b7 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:48:41 -0700 Subject: [PATCH 51/63] Boolean checking if a String value exists in set. --- src/SetPractice.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SetPractice.java b/src/SetPractice.java index b6cc273..2cc81e2 100644 --- a/src/SetPractice.java +++ b/src/SetPractice.java @@ -13,6 +13,8 @@ public static void main(String[] args) { mySet.add("Third"); // Check whether the Set contains a given String + boolean containsString = mySet.contains("Second"); // checking if a given string exists in set + System.out.println("Set contains string: " + containsString); // Remove an element from the Set From 6f28f114f600209a9ea1f897d1a61d9f2e3f2a3b Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:49:10 -0700 Subject: [PATCH 52/63] removing value from set --- src/SetPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SetPractice.java b/src/SetPractice.java index 2cc81e2..e2371c1 100644 --- a/src/SetPractice.java +++ b/src/SetPractice.java @@ -17,6 +17,7 @@ public static void main(String[] args) { System.out.println("Set contains string: " + containsString); // Remove an element from the Set + mySet.remove("Second"); // Get the size of the Set From 7f99e89c954e7593f091f0974fcb7ab8cf2138c1 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:50:02 -0700 Subject: [PATCH 53/63] Iterating over each element, printed on a separate line. --- src/SetPractice.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/SetPractice.java b/src/SetPractice.java index e2371c1..46bb5c2 100644 --- a/src/SetPractice.java +++ b/src/SetPractice.java @@ -20,8 +20,12 @@ public static void main(String[] args) { mySet.remove("Second"); // Get the size of the Set + int setSize = mySet.size(); // size of the set // Iterate over the elements of the Set, printing each one on a separate line + for(String item : mySet){ // using for-each loop to iterate over the set + System.out.println(item); + } /* * Warning! From 780ba2e554181f14670994860b7af14c2b4e7f40 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:56:07 -0700 Subject: [PATCH 54/63] String variable made --- src/StringPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/StringPractice.java b/src/StringPractice.java index 8d87617..216b2a3 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -1,6 +1,7 @@ public class StringPractice { public static void main(String[] args) { // Create a string with at least 5 characters and assign it to a variable + String fiveLetterString = "Hello"; // Find the length of the string From 2a05c76c402e8bdbad9cfa92b76b89c783180daf Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:58:25 -0700 Subject: [PATCH 55/63] New string made from concatenation --- src/StringPractice.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/StringPractice.java b/src/StringPractice.java index 216b2a3..ded43d2 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -4,8 +4,11 @@ public static void main(String[] args) { String fiveLetterString = "Hello"; // Find the length of the string + fiveLetterString.length(); + // Concatenate (add) two strings together and reassign the result + String newString = fiveLetterString + "World"; // Concatenating two strings together // Find the value of the character at index 3 From 3686d275d05eae2ec9591a2dbcabeeaabe89f2ba Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:58:52 -0700 Subject: [PATCH 56/63] char variable finding what character is at index 3 --- src/StringPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/StringPractice.java b/src/StringPractice.java index ded43d2..bbdfa6d 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -11,6 +11,7 @@ public static void main(String[] args) { String newString = fiveLetterString + "World"; // Concatenating two strings together // Find the value of the character at index 3 + char charAtIndex3 = fiveLetterString.charAt(3); // Getting the character at index 3 // Check whether the string contains a given substring (i.e. does the string have "abc" in it?) From e6e018beab9b057a6814d07cd9487cf0f098bf63 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 22:59:30 -0700 Subject: [PATCH 57/63] Checking if string contains a substring --- src/StringPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/StringPractice.java b/src/StringPractice.java index bbdfa6d..f2514f9 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -14,6 +14,7 @@ public static void main(String[] args) { char charAtIndex3 = fiveLetterString.charAt(3); // Getting the character at index 3 // Check whether the string contains a given substring (i.e. does the string have "abc" in it?) + boolean checkSubstring = fiveLetterString.contains("llo"); // Iterate over the characters of the string, printing each one on a separate line From f5a419d405bc4a458e716e70886c6947083472ce Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 23:00:25 -0700 Subject: [PATCH 58/63] Iterating through string to print each character --- src/StringPractice.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/StringPractice.java b/src/StringPractice.java index f2514f9..e139fbc 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -17,6 +17,9 @@ public static void main(String[] args) { boolean checkSubstring = fiveLetterString.contains("llo"); // Iterate over the characters of the string, printing each one on a separate line + for(int i = 0; i < fiveLetterString.length(); i++){ + System.out.println(fiveLetterString.charAt(i)); // using charAt to print each index + } // Create an ArrayList of Strings and assign it to a variable From 5913ef717d960a866221307b7612fe4c75c4ec39 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 23:00:57 -0700 Subject: [PATCH 59/63] Importing ArrayList --- src/StringPractice.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/StringPractice.java b/src/StringPractice.java index e139fbc..f937fd0 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -1,4 +1,7 @@ -public class StringPractice { +import java.util.ArrayList; + +public class StringPractice { + public static void main(String[] args) { // Create a string with at least 5 characters and assign it to a variable String fiveLetterString = "Hello"; From 68d84c08114efbc395f64208648160e2b5217a8a Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 23:01:21 -0700 Subject: [PATCH 60/63] New ArrayList variable --- src/StringPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/StringPractice.java b/src/StringPractice.java index f937fd0..6e3bdfa 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -25,6 +25,7 @@ public static void main(String[] args) { } // Create an ArrayList of Strings and assign it to a variable + ArrayList myArrayList = new ArrayList<>(); // Add multiple strings to the List (OK to do one-by-one) From 08ed005e57651e1518714c45ec22b806de4283a5 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 23:01:51 -0700 Subject: [PATCH 61/63] Multiple string elements added to list --- src/StringPractice.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/StringPractice.java b/src/StringPractice.java index 6e3bdfa..61fd01a 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -28,6 +28,9 @@ public static void main(String[] args) { ArrayList myArrayList = new ArrayList<>(); // Add multiple strings to the List (OK to do one-by-one) + myArrayList.add("First"); + myArrayList.add("Second"); + myArrayList.add("Third"); // Join all of the strings in the list together into a single string separated by commas // Use a built-in method to achieve this instead of using a loop From e84eebd8476880155a7980e13dd3ba08ecd6596c Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 23:02:30 -0700 Subject: [PATCH 62/63] Using join() to join entire arrayList into one string separated by commas --- src/StringPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/StringPractice.java b/src/StringPractice.java index 61fd01a..f6fa5d4 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -34,6 +34,7 @@ public static void main(String[] args) { // Join all of the strings in the list together into a single string separated by commas // Use a built-in method to achieve this instead of using a loop + String joinedString = String.join(",", myArrayList); // Joining the strings in the list together with commas using .join(); // Check whether two strings are equal From c328d962e77793c495baf9dca705284317bb4803 Mon Sep 17 00:00:00 2001 From: Jaron Date: Fri, 20 Mar 2026 23:03:10 -0700 Subject: [PATCH 63/63] Using .equals() and a boolean to check if two strings are equal --- src/StringPractice.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/StringPractice.java b/src/StringPractice.java index f6fa5d4..c2098df 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -37,6 +37,10 @@ public static void main(String[] args) { String joinedString = String.join(",", myArrayList); // Joining the strings in the list together with commas using .join(); // Check whether two strings are equal + String string1 = "Hello"; + String string2 = "world"; + + boolean stringsEqual = string1.equals(string2); // Checking if two strings are equal with .equals() /* * Reminder!