From 62552ef6d11103f60f9e1c31b38d95e96b2bccb9 Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Mon, 29 Sep 2025 14:13:59 -0700 Subject: [PATCH 01/23] Added a print statement to the Array file --- src/ArrayPractice.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index bc58c83..cc34152 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -1,11 +1,17 @@ public class ArrayPractice { public static void main(String[] args) { // Create an array of Strings of size 4 + String words[] = 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 + words[0] = "Bike"; + words[1] = "Car"; + words[2] = "Boat"; + words[3] = "Motorcycle"; // Get the value of the array at index 2 + System.out.println(words[1]); // Get the length of the array From 0c4b9777ffbe3a8f4387348836cb95a13de0d10c Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Mon, 29 Sep 2025 14:33:55 -0700 Subject: [PATCH 02/23] Added a traditional for loop and a for each loop to the Array file --- src/ArrayPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index cc34152..106693f 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -14,6 +14,7 @@ public static void main(String[] args) { System.out.println(words[1]); // Get the length of the array + System.out.println(words.length); // Iterate over the array using a traditional for loop and print out each item From 4dbd5a2b984483980de26e339ae19d0600f738ea Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Mon, 29 Sep 2025 15:13:53 -0700 Subject: [PATCH 03/23] Imported java.util.ArrayList and List --- src/ListPractice.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ListPractice.java b/src/ListPractice.java index f4de8e7..e465abb 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -1,8 +1,13 @@ +import java.util.ArrayList; +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 + List words = new ArrayList<>(); + // Add 3 elements to the list (OK to do one-by-one) From a268f80e18020a0fc49214720a6d86f1a9af5aa2 Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Mon, 29 Sep 2025 15:33:21 -0700 Subject: [PATCH 04/23] Replaced an element at index 1 of the list --- src/ListPractice.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index e465abb..1507de3 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -10,14 +10,19 @@ public static void main(String[] args) { // Add 3 elements to the list (OK to do one-by-one) - + words.add("Marvel Comics"); + words.add("Detective Comics"); + words.add("Image Comics"); // Print the element at index 1 + System.out.println(words.get(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) + words.set(1, "Dark Horse Comics"); + System.out.println(words.get(1)); // Insert a new element at index 0 (the length of the list will change) - + words.add(0, "IDW Publishing"); // Check whether the list contains a certain string // Iterate over the list using a traditional for-loop. From 6fe1beabd156c74ed718119aa5a7c208ead2730d Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Mon, 29 Sep 2025 16:43:45 -0700 Subject: [PATCH 05/23] Created a for loop to iterate over the list --- src/ListPractice.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index 1507de3..0d14afe 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -23,12 +23,18 @@ public static void main(String[] args) { // Insert a new element at index 0 (the length of the list will change) words.add(0, "IDW Publishing"); + // Check whether the list contains a certain string + System.out.println(words.contains("Dark Horse Comics")); // Iterate over the list using a traditional for-loop. - // Print each index and value on a separate line + for (int i = 0; i < words.size(); i++) { + // Print each index and value on a separate line + System.out.println(words.get(i)); + } // Sort the list using the Collections library + // Iterate over the list using a for-each loop // Print each value on a second line From 3a69fa845d309e53631bb59005fca3fc41f79a56 Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Mon, 29 Sep 2025 16:58:55 -0700 Subject: [PATCH 06/23] Created a for each loop and printed each value on a second line --- src/ListPractice.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index 0d14afe..4155c8e 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -1,4 +1,5 @@ import java.util.ArrayList; +import java.util.Collections; import java.util.List; public class ListPractice { @@ -34,11 +35,16 @@ public static void main(String[] args) { System.out.println(words.get(i)); } // Sort the list using the Collections library - + System.out.println("before sort: " + words); + Collections.sort(words); + System.out.println("after sort: " + words); // Iterate over the list using a for-each loop - // Print each value on a second line + for (String word : words) { + // Print each value on a second line + System.out.println(word); + } /* * Usage tip! * From bd6f491d60372901db1119b1927f1908aed2c304 Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Mon, 29 Sep 2025 18:52:57 -0700 Subject: [PATCH 07/23] Created a HashMap, added 3 different key value pairs, and printed out the value associated with a given key --- src/MapPractice.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/MapPractice.java b/src/MapPractice.java index 7ebfeac..7614ddd 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -1,14 +1,21 @@ - +import java.util.HashMap; +import java.util.Map; 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 + Map map = new HashMap<>(); // Put 3 different key/value pairs in the Map // (it's OK to do this one-by-one) + map.put("Xavier", 1); + map.put("Jhoanna", 2); + map.put("Thor", 3); // Get the value associated with a given key in the Map + int value = map.get("Xavier"); + System.out.println("The value associated with key: 'Xavier' is " + value); // Find the size (number of key/value pairs) of the Map From c1b556a5adf8fc10262a6ba7f19c23521023a834 Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Mon, 29 Sep 2025 18:59:20 -0700 Subject: [PATCH 08/23] Created a for loop and a for each loop to print out each item --- src/ArrayPractice.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index 106693f..f549c8f 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -17,8 +17,13 @@ public static void main(String[] args) { System.out.println(words.length); // Iterate over the array using a traditional for loop and print out each item - + for (int i = 0; i < words.length; i++) { + System.out.println(words[i]); + } // Iterate over the array using a for-each loop and print out each item + for (String word : words) { + System.out.println(word); + } /* * Reminder! From 9189ec769fe4da8154759dab8fe8a2a8a2e65ac6 Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Mon, 29 Sep 2025 19:34:10 -0700 Subject: [PATCH 09/23] Added a print statement to output the size of the map and replaced key: Thor's value with 23 --- src/MapPractice.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/MapPractice.java b/src/MapPractice.java index 7614ddd..1a574ca 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -18,12 +18,18 @@ public static void main(String[] args) { System.out.println("The value associated with key: 'Xavier' is " + value); // Find the size (number of key/value pairs) of the Map + System.out.println("The size of the map is: " + map.size()); // Replace the value associated with a given key (the size of the Map shoukld not change) + map.replace("Thor", 23); + System.out.println(map.get("Thor")); + System.out.println(map.size()); // Check whether the Map contains a given key + System.out.println(map.containsKey("Xavier")); // Check whether the Map contains a given value + // Iterate over the keys of the Map, printing each key From a77e206c158acd7c0d02553fecb4eed96f82da55 Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Mon, 29 Sep 2025 20:03:54 -0700 Subject: [PATCH 10/23] Added a print statement checking if the map contain a given value, and 2 for each loops printing out keys and values seperately --- src/MapPractice.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/MapPractice.java b/src/MapPractice.java index 1a574ca..b2d136f 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -1,5 +1,6 @@ import java.util.HashMap; import java.util.Map; +import java.util.Set; public class MapPractice { public static void main(String[] args) { @@ -29,13 +30,20 @@ public static void main(String[] args) { System.out.println(map.containsKey("Xavier")); // Check whether the Map contains a given value - + System.out.println(map.containsValue(23)); // Iterate over the keys of the Map, printing each key + for (String key : map.keySet()) { + System.out.println(key); + } // Iterate over the values of the map, printing each value + for (Integer val : map.values()) { + System.out.println(val); + } // Iterate over the entries in the map, printing each key and value + /* * Usage tip! From 42bcdbe447ac1e2c8eb4255a1d8c1b01071dd6c4 Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Mon, 29 Sep 2025 21:12:26 -0700 Subject: [PATCH 11/23] Added a for each loop to iterate through the map and print out key and value pairs --- src/MapPractice.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/MapPractice.java b/src/MapPractice.java index b2d136f..bf1e089 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -43,7 +43,9 @@ public static void main(String[] args) { } // Iterate over the entries in the map, printing each key and value - + for (Map.Entry entry : map.entrySet()) { + System.out.println(entry.getKey() + " --> " + entry.getValue()); + } /* * Usage tip! From 8423fba5c5d8d18ad3964f5e08c2344581209b6e Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Mon, 29 Sep 2025 22:02:47 -0700 Subject: [PATCH 12/23] Used modulo to find the remainder when the int is divided by 3 --- src/NumberPractice.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NumberPractice.java b/src/NumberPractice.java index bbec2fe..f9adab5 100644 --- a/src/NumberPractice.java +++ b/src/NumberPractice.java @@ -1,12 +1,17 @@ public class NumberPractice { public static void main(String args[]) { // Create a float with a negative value and assign it to a variable + float negativeNum = -9.0f; // Create an int with a positive value and assign it to a variable + int positiveNum = 5; // Use the modulo % operator to find the remainder when the int is divided by 3 + int remainder = positiveNum % 3; + System.out.println(positiveNum + " % 3 = " + 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) // Use an if-else to print "Even" if the number is even and "Odd" // if the number is odd. From 15020ecadb296fae0f9d79348fff7fcbcb1f4bb0 Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Mon, 29 Sep 2025 22:25:44 -0700 Subject: [PATCH 13/23] Created an if-else statement and performed integer division --- src/NumberPractice.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/NumberPractice.java b/src/NumberPractice.java index f9adab5..16bf0c6 100644 --- a/src/NumberPractice.java +++ b/src/NumberPractice.java @@ -1,22 +1,29 @@ public class NumberPractice { public static void main(String args[]) { // Create a float with a negative value and assign it to a variable - float negativeNum = -9.0f; + float negativeNum = -10.0f; // Create an int with a positive value and assign it to a variable - int positiveNum = 5; + int positiveNum = 10; // Use the modulo % operator to find the remainder when the int is divided by 3 int remainder = positiveNum % 3; System.out.println(positiveNum + " % 3 = " + 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) // Use an if-else to print "Even" if the number is even and "Odd" // if the number is odd. + if (negativeNum % 2 == 0) { + System.out.println("Even"); + } + else { + System.out.println("Odd"); + } // Divide the number by another number using integer division + int quotient = positiveNum / 5; + System.out.println("Answer: " + quotient); /* * Reminder! From b6a87c70b4c3f7f1353d9dfb6b452efa64cb6bb9 Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Mon, 29 Sep 2025 23:00:56 -0700 Subject: [PATCH 14/23] Created instance variables for name and age and a parameterized constructor for Person --- src/Person.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Person.java b/src/Person.java index 8ab3f95..b06d74d 100644 --- a/src/Person.java +++ b/src/Person.java @@ -5,11 +5,18 @@ 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; // instance variable (can be accessed outside class ) + // Declare a private int instance variable for the age of the person + private int age;// can only be accessed within the class (private) // Create a constructor that takes the name and age of the person + public Person(String name, int age) { // and assigns it to the instance variables + this.name = name; + this.age = age; + } + // Create a toString method that gives the name and age of the person From f4c411a194978a7eb869fd18ee18c05774c02e0f Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Mon, 29 Sep 2025 23:06:12 -0700 Subject: [PATCH 15/23] Created a toString method for the name and age --- src/Person.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Person.java b/src/Person.java index b06d74d..5f6a7eb 100644 --- a/src/Person.java +++ b/src/Person.java @@ -17,10 +17,10 @@ public Person(String name, int age) { this.age = age; } - - // Create a toString method that gives the name and age of the person - + public String toString() { + return "name: " + name + " age" + age; + } // Implement the below public instance method "birthYear" // There should NOT be any print statement in this method. From ee076593509bd4c00a5656d582443d16220d98a3 Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Tue, 30 Sep 2025 08:35:24 -0700 Subject: [PATCH 16/23] Added a birthYear method to return the birth year of the person --- src/Person.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Person.java b/src/Person.java index 5f6a7eb..0178fde 100644 --- a/src/Person.java +++ b/src/Person.java @@ -19,7 +19,7 @@ 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 + " age" + age; + return "name: " + name + " age: " + age; } // Implement the below public instance method "birthYear" @@ -35,15 +35,22 @@ public String toString() { * @return The year the person was born */ // (create the instance method here) + public int birthYear(int currentYear) { + int yearOfBirth = currentYear - age; + return yearOfBirth; + } public static void main(String[] args) { // Create an instance of Person + Person p = new Person("Xavier", 35); // Create another instance of Person with a different name and age and // assign it to a different variable + Person pTwo = new Person("Jhoanna", 36); // Print the first person + System.out.println(p); // Print the second person From 9ddcb62ce47936af74c4ee8b0e1e4416db56832a Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Tue, 30 Sep 2025 08:40:52 -0700 Subject: [PATCH 17/23] Created two instances of Person and printed out both --- src/Person.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Person.java b/src/Person.java index 0178fde..868c95c 100644 --- a/src/Person.java +++ b/src/Person.java @@ -53,6 +53,7 @@ public static void main(String[] args) { System.out.println(p); // Print the second person + System.out.println(pTwo); // Get the name of the first person and store it in a local variable From 1a9585d9ebeb9411d4fa6988ac5da0234c0fbb22 Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Tue, 30 Sep 2025 08:50:51 -0700 Subject: [PATCH 18/23] Added a getter method for name and called the method in the main. --- src/Person.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Person.java b/src/Person.java index 868c95c..9bbf176 100644 --- a/src/Person.java +++ b/src/Person.java @@ -40,6 +40,11 @@ public int birthYear(int currentYear) { return yearOfBirth; } + // Getter Method + public String getName() { + return this.name; + } + public static void main(String[] args) { // Create an instance of Person @@ -56,7 +61,8 @@ public static void main(String[] args) { System.out.println(pTwo); // Get the name of the first person and store it in a local variable - + System.out.println(p.getName()); + // 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. From 16871fed774457b587a668f129d41bdb9f99494b Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Tue, 30 Sep 2025 08:58:09 -0700 Subject: [PATCH 19/23] Stored the birth year of the first person in a variable and printed out the birth year of that person --- src/Person.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Person.java b/src/Person.java index 9bbf176..3cde769 100644 --- a/src/Person.java +++ b/src/Person.java @@ -66,8 +66,10 @@ 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 bornYear = p.birthYear(2025); // In a separate statement, print the local variable holding the birth year. + System.out.println("The year of birth for " + p.getName() + " is: " + bornYear); /** * Terminology! From 491ec7424677be4574c172656c527ecb6c1a5ded Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Tue, 30 Sep 2025 10:16:19 -0700 Subject: [PATCH 20/23] Created a new HashSet and assigned it to a variable of type set --- src/SetPractice.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/SetPractice.java b/src/SetPractice.java index d2fc1c9..dd7b5ad 100644 --- a/src/SetPractice.java +++ b/src/SetPractice.java @@ -1,9 +1,13 @@ +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 + HashSet words = new HashSet<>(); // Add 3 elements to the set // (It's OK to do it one-by-one) + // Check whether the Set contains a given String From 510357e348b7bd90207b17a2c408000c3ed8edb8 Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Tue, 30 Sep 2025 19:15:12 -0700 Subject: [PATCH 21/23] Added a for each loop to iterate over elements in the HashSet --- src/SetPractice.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/SetPractice.java b/src/SetPractice.java index dd7b5ad..bc534b6 100644 --- a/src/SetPractice.java +++ b/src/SetPractice.java @@ -1,21 +1,30 @@ -import java.util.HashSet +import java.util.HashSet; +import java.util.Set; public class SetPractice { public static void main(String[] args) { // Create a HashSet of Strings and assign it to a variable of type Set - HashSet words = new HashSet<>(); + Set words = new HashSet<>(); // Add 3 elements to the set // (It's OK to do it one-by-one) + words.add("The"); + words.add("Fantastic"); + words.add("Four"); - // Check whether the Set contains a given String + System.out.println(words.contains("Fantastic")); // Remove an element from the Set + words.remove("Four"); // Get the size of the Set + System.out.println(words.size()); // Iterate over the elements of the Set, printing each one on a separate line + for (String word : words) { + System.out.println(word); + } /* * Warning! From 13afa4a1b8fe23dd7124f75136c1a411c3f27872 Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Tue, 30 Sep 2025 20:00:24 -0700 Subject: [PATCH 22/23] Checked whether a string contains a given substring --- src/StringPractice.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/StringPractice.java b/src/StringPractice.java index 8d87617..a2c448d 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -1,14 +1,24 @@ public class StringPractice { public static void main(String[] args) { // Create a string with at least 5 characters and assign it to a variable - + String firstName = "Xavier"; // Find the length of the string + int nameLength = firstName.length(); + System.out.println("Length of name: " + nameLength); // Concatenate (add) two strings together and reassign the result + String lastName = "Lewis"; + + String fullName = firstName + " " + lastName; + + System.out.println(fullName); // Find the value of the character at index 3 + char c = fullName.charAt(3); + System.out.println("The value of the character at index 3 is: " + c); // Check whether the string contains a given substring (i.e. does the string have "abc" in it?) + System.out.println(fullName.contains("abc")); // Iterate over the characters of the string, printing each one on a separate line From 369f5b9bf587d768cb2a085644fcbbf2440d49d1 Mon Sep 17 00:00:00 2001 From: SouthBennett <146032836+SouthBennett@users.noreply.github.com> Date: Tue, 30 Sep 2025 20:23:28 -0700 Subject: [PATCH 23/23] Checked whether two strings are equal --- src/StringPractice.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/StringPractice.java b/src/StringPractice.java index a2c448d..1dc7cea 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -1,3 +1,5 @@ +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 @@ -21,16 +23,31 @@ public static void main(String[] args) { System.out.println(fullName.contains("abc")); // Iterate over the characters of the string, printing each one on a separate line + for (int i = 0; i < lastName.length(); i++) { + char w = lastName.charAt(i); + System.out.println("Character at index " + i + " is " + w); + } // Create an ArrayList of Strings and assign it to a variable + ArrayList words = new ArrayList<>(); // Add multiple strings to the List (OK to do one-by-one) + words.add("Apple"); + words.add("Banana"); + words.add("Orange"); // 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 joinedStrings = String.join("," , words); + System.out.println(joinedStrings); // Check whether two strings are equal - + if (firstName.equals(lastName)) { + System.out.println("equal"); + } else { + System.out.println("not equal"); + } + /* * Reminder! *