From c447125bbe0f502421f8a8788b20d0172cdeb9d3 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 01:58:40 -0700 Subject: [PATCH 01/35] created an array name my array that hold 4 strings --- src/ArrayPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index bc58c83..acd249f 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -1,6 +1,7 @@ public class ArrayPractice { public static void main(String[] args) { // Create an array of Strings of size 4 + String[] myArray = 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 From c0cd6881250fb6788999550300cd3af114fd30d6 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 02:53:00 -0700 Subject: [PATCH 02/35] set the five value with their index --- src/ArrayPractice.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index acd249f..179010a 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -1,10 +1,15 @@ public class ArrayPractice { public static void main(String[] args) { // Create an array of Strings of size 4 - String[] myArray = new String[4]; - + String[]myArray; + myArray = 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 + + myArray[0] = "Green River"; + myArray[1] = "Seattle Central"; + myArray[2] = "Highline"; + myArray[3] = "South Seattle"; // Get the value of the array at index 2 From a035beb21d61bba456f83cb883e743933440fa4a Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 02:56:40 -0700 Subject: [PATCH 03/35] run code get highline --- src/ArrayPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index 179010a..09f2f56 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -12,6 +12,7 @@ public static void main(String[] args) { myArray[3] = "South Seattle"; // Get the value of the array at index 2 + System.out.println(myArray[2]); // Get the length of the array From a2ad92efc1464cfd3393a68138995eb439923460 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 02:59:53 -0700 Subject: [PATCH 04/35] the length of an array 4 --- src/ArrayPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index 09f2f56..1edf248 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -15,6 +15,7 @@ public static void main(String[] args) { System.out.println(myArray[2]); // Get the length of the array + System.out.println(myArray.length); // Iterate over the array using a traditional for loop and print out each item From 52b391e696cee2cf14d36c653d7b20cc436db8b1 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 03:14:15 -0700 Subject: [PATCH 05/35] accessed each element using for loop --- src/ArrayPractice.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index 1edf248..25d14b9 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -18,7 +18,9 @@ public static void main(String[] args) { System.out.println(myArray.length); // Iterate over the array using a traditional for loop and print out each item - + for (int i =0; i Date: Wed, 1 Oct 2025 03:26:47 -0700 Subject: [PATCH 06/35] used for each loop to get each element --- src/ArrayPractice.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index 25d14b9..e379a63 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -22,11 +22,15 @@ public static void main(String[] args) { System.out.println("Element at index " + i + ": " +myArray[i]); } // Iterate over the array using a for-each loop and print out each item - + for (String myArray1 : myArray ){ + System.out.println(myArray1); + } + + } /* * Reminder! * * Arrays start at index 0 */ } -} + From e945579c6e6d0daa9ee4e6819c9030d1aede19f0 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 12:54:40 -0700 Subject: [PATCH 07/35] first I imported java .util.list.Then I created an empty arratlist of strings and added three elements --- src/ListPractice.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index f4de8e7..d36299e 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -1,13 +1,19 @@ +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 + Listlist = new ArrayList<>(); // Add 3 elements to the list (OK to do one-by-one) - + list.add("Ebtisam"); + list.add("Manar"); + list.add("Afnan"); // Print the element at index 1 - + System.out.println(list.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) From c162cd8223f00b04a1edfcbcefa4a79ef38971b3 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 13:04:19 -0700 Subject: [PATCH 08/35] I used the set method and replace index 1 with out changing the ength of hte list --- src/ListPractice.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index d36299e..c3644c8 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -12,9 +12,11 @@ public static void main(String[] args) { list.add("Ebtisam"); list.add("Manar"); list.add("Afnan"); + list.set(1,"Semah"); // Print the element at index 1 - System.out.println(list.get(1)); + //System.out.println(list.get(1)); // Replace the element at index 1 with a new value + System.out.println(list); // (Do not insert a new value. The length of the list should not change) // Insert a new element at index 0 (the length of the list will change) From 4bc80fb5c9b2bcad61c064a7cefe392edfeac599 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 13:08:45 -0700 Subject: [PATCH 09/35] Created a new element and used the add method and the length has been changed to 4 --- src/ListPractice.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ListPractice.java b/src/ListPractice.java index c3644c8..6603756 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -13,9 +13,11 @@ public static void main(String[] args) { list.add("Manar"); list.add("Afnan"); list.set(1,"Semah"); + list.add(0,"Abdulaziz"); // Print the element at index 1 //System.out.println(list.get(1)); // Replace the element at index 1 with a new value + //I used the set method to replace the list with new value. System.out.println(list); // (Do not insert a new value. The length of the list should not change) From 0e4fbc7dc0e75b53e90f825d77cf2dfb8e944fad Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 13:22:23 -0700 Subject: [PATCH 10/35] I used list.contains to check a if it contains certain string (manar) return false. --- src/ListPractice.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index 6603756..d2917e8 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -18,13 +18,13 @@ public static void main(String[] args) { //System.out.println(list.get(1)); // Replace the element at index 1 with a new value //I used the set method to replace the list with new value. - System.out.println(list); + //System.out.println(list); // (Do not insert a new value. The length of the list should not change) // Insert a new element at index 0 (the length of the list will change) - + // I used add method to add the element. // Check whether the list contains a certain string - + System.out.println("Contains a certain string manar :" + list.contains("manar")); // Iterate over the list using a traditional for-loop. // Print each index and value on a separate line From 1758a20a6df72e3c2c25752e9543f88e22ddbc96 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 13:48:16 -0700 Subject: [PATCH 11/35] for-loop created and the index and value in newline. --- src/ListPractice.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index d2917e8..72449d7 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 { @@ -25,14 +26,24 @@ public static void main(String[] args) { // I used add method to add the element. // Check whether the list contains a certain string System.out.println("Contains a certain string manar :" + list.contains("manar")); + // Iterate over the list using a traditional for-loop. // Print each index and value on a separate line + for (int i =0; i Date: Wed, 1 Oct 2025 17:29:16 -0700 Subject: [PATCH 12/35] the last two steps I sorted the elements using collections.sorrt. and used each loop --- src/MapPractice.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/MapPractice.java b/src/MapPractice.java index 7ebfeac..b4d07d7 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -1,9 +1,11 @@ - +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 people = new HashMap<>(); // Put 3 different key/value pairs in the Map // (it's OK to do this one-by-one) From 1d168033637e23a437f7066a1de49e1c37eb9c5d Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 17:30:31 -0700 Subject: [PATCH 13/35] created hashMap called people. --- src/MapPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MapPractice.java b/src/MapPractice.java index b4d07d7..42a86a7 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -9,6 +9,7 @@ public static void main(String[] args) { // Put 3 different key/value pairs in the Map // (it's OK to do this one-by-one) + // Get the value associated with a given key in the Map From 322ec7cf24fdcacb2c9d47ed9eb10d50322e9a6b Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 17:34:02 -0700 Subject: [PATCH 14/35] used put method to add three people key and value --- src/MapPractice.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/MapPractice.java b/src/MapPractice.java index 42a86a7..f4c5b17 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -9,7 +9,10 @@ public static void main(String[] args) { // Put 3 different key/value pairs in the Map // (it's OK to do this one-by-one) - + + people.put("Manar", 10); + people.put("Afnan", 6); + people.put("Semah", 4); // Get the value associated with a given key in the Map From 6ef387c2545c4ba725643e12fd89d76a1476414d Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 17:40:13 -0700 Subject: [PATCH 15/35] for loop to get the value associated with the key in the map --- src/MapPractice.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/MapPractice.java b/src/MapPractice.java index f4c5b17..2a99d41 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -15,6 +15,9 @@ public static void main(String[] args) { people.put("Semah", 4); // Get the value associated with a given key in the Map + for(String i:people.keySet() ){ + System.out.println("key: " + i + "value: " + people.get(i)); + } // Find the size (number of key/value pairs) of the Map From 2f34ac4e180d4fe1bcc2b646961c4cb4f6854701 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 17:45:21 -0700 Subject: [PATCH 16/35] used size()method --- src/MapPractice.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/MapPractice.java b/src/MapPractice.java index 2a99d41..0bf70e1 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -16,10 +16,11 @@ public static void main(String[] args) { // Get the value associated with a given key in the Map for(String i:people.keySet() ){ - System.out.println("key: " + i + "value: " + people.get(i)); + System.out.println("key: " + i + " value: " + people.get(i)); } // Find the size (number of key/value pairs) of the Map + System.out.println(people.size()); // Replace the value associated with a given key (the size of the Map shoukld not change) From 4d0409d22f7149372f9811181cfc764c23611cc2 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 17:58:49 -0700 Subject: [PATCH 17/35] using the replace and by specifing which string to be change using keyToReplace and giving the integer or the value name to newValue --- src/MapPractice.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/MapPractice.java b/src/MapPractice.java index 0bf70e1..bfcb6c9 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -23,7 +23,10 @@ public static void main(String[] args) { System.out.println(people.size()); // Replace the value associated with a given key (the size of the Map shoukld not change) - + String keyToReplace ="Afnan"; + Integer newValue = 5; + people.replace(keyToReplace,newValue); + System.out.println(people); // Check whether the Map contains a given key // Check whether the Map contains a given value From 374e7d80e9fdc7797e7d18194fa3c719fe6119a6 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 18:11:32 -0700 Subject: [PATCH 18/35] cheched if each key and value have the element by using the method containsKey and containsValue --- src/MapPractice.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/MapPractice.java b/src/MapPractice.java index bfcb6c9..83bb622 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -28,8 +28,9 @@ public static void main(String[] args) { people.replace(keyToReplace,newValue); System.out.println(people); // Check whether the Map contains a given key - + System.out.println("Is the given key Semah present?" + people.containsKey("Semah")); // Check whether the Map contains a given value + System.out.println("Is the given value 3 present?" + people.containsValue(3)); // Iterate over the keys of the Map, printing each key From 147343a42c16c8e0ef9011f92a2897fd773fd040 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 18:27:31 -0700 Subject: [PATCH 19/35] used map.keyset() method returns the key and map.values returns the value which is the age so to iterate i used for -each loop --- src/MapPractice.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/MapPractice.java b/src/MapPractice.java index 83bb622..dc6761f 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -33,11 +33,15 @@ public static void main(String[] args) { System.out.println("Is the given value 3 present?" + people.containsValue(3)); // Iterate over the keys of the Map, printing each key - + for(String name: people.keySet()){ + System.out.println("key:" + name); + } // Iterate over the values of the map, printing each value - + for(Integer age: people.values()){ + System.out.println("valu:" + age); + } // Iterate over the entries in the map, printing each key and value - + /* * Usage tip! * From 8fe654467a5691fedc510eb3bbfa5fae2708930d Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 18:41:56 -0700 Subject: [PATCH 20/35] loo over the keys and searching for the value --- src/MapPractice.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/MapPractice.java b/src/MapPractice.java index dc6761f..6bbd089 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -41,8 +41,10 @@ public static void main(String[] args) { System.out.println("valu:" + age); } // Iterate over the entries in the map, printing each key and value - - /* + for(String i: people.keySet()){ + Integer age = people.get(i); + System.out.println("key: " + i + " valu: " + age); + }/* * Usage tip! * * Maps are great when you want a specific key to value mapping. From 52c24ea498b31bb670f6a014bdd84e88a09e9b72 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 18:56:15 -0700 Subject: [PATCH 21/35] float is a fraction number or decimal. integer is a whole number. modulo is remider i divided 8 by 3 and I have a remider of two --- src/NumberPractice.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/NumberPractice.java b/src/NumberPractice.java index bbec2fe..40daabc 100644 --- a/src/NumberPractice.java +++ b/src/NumberPractice.java @@ -1,11 +1,16 @@ public class NumberPractice { public static void main(String args[]) { // Create a float with a negative value and assign it to a variable - + float myFloat = -6.1f; + System.out.println(myFloat); // Create an int with a positive value and assign it to a variable - + int myInt = 250; + System.out.println(myInt); // Use the modulo % operator to find the remainder when the int is divided by 3 - + int a = 8; + int b = 3; + int x = a%b; + System.out.println(x); // 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" From 7acae54e0ffaf3392f571a49ca93669f48fdc283 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 19:10:25 -0700 Subject: [PATCH 22/35] get the even or odd by using modulo operation when divid 8 by 2 the reminder is zero which means even. if i divid 8 by 3 the reminder is two which means odd. --- src/NumberPractice.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NumberPractice.java b/src/NumberPractice.java index 40daabc..9e27a04 100644 --- a/src/NumberPractice.java +++ b/src/NumberPractice.java @@ -15,6 +15,12 @@ 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 (a % 2 == 0){ + System.out.println(a + " Even"); + }else{ + System.out.println(a + " Odd"); + } + // Divide the number by another number using integer division From 0c55e75c46e84cfdba0e40a7c53c2ea0261290d3 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 19:16:26 -0700 Subject: [PATCH 23/35] divide two integers and the result will be rounded or the remaider is ignored. --- src/NumberPractice.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/NumberPractice.java b/src/NumberPractice.java index 9e27a04..59dbdb5 100644 --- a/src/NumberPractice.java +++ b/src/NumberPractice.java @@ -23,7 +23,10 @@ public static void main(String args[]) { // Divide the number by another number using integer division - + int c = 18; + int d = 5; + int y =c/d ; + System.out.println(y); /* * Reminder! * From e0f331a227989db6314dcb891c61524993dd9792 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 19:56:31 -0700 Subject: [PATCH 24/35] from the person class declare as a public string (name) and private int(age) --- src/ListPractice.java | 4 ++-- src/Person.java | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index 72449d7..347b86c 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -16,10 +16,10 @@ public static void main(String[] args) { list.set(1,"Semah"); list.add(0,"Abdulaziz"); // Print the element at index 1 - //System.out.println(list.get(1)); + System.out.println(list.get(1)); // Replace the element at index 1 with a new value //I used the set method to replace the list with new value. - //System.out.println(list); + System.out.println(list); // (Do not insert a new value. The length of the list should not change) // Insert a new element at index 0 (the length of the list will change) diff --git a/src/Person.java b/src/Person.java index 8ab3f95..ef261c6 100644 --- a/src/Person.java +++ b/src/Person.java @@ -5,9 +5,12 @@ 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; +// Declare a private int instance variable for the age of the person + private int age; + + // Create a constructor that takes the name and age of the person // and assigns it to the instance variables From 5015cf4f7fc3df735309bb082b6a545a3554d693 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 20:15:18 -0700 Subject: [PATCH 25/35] created a Hashset object called shools. Then I added each element using add method --- src/Person.java | 10 +++++----- src/SetPractice.java | 9 ++++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Person.java b/src/Person.java index ef261c6..beb490a 100644 --- a/src/Person.java +++ b/src/Person.java @@ -6,14 +6,14 @@ public class Person { // Declare a public String instance variable for the name of the person public String name; -// Declare a private int instance variable for the age of the person + // Declare a private int instance variable for the age of the person private int age; - - // Create a constructor that takes the name and age of the person - // and assigns it to the instance variables - + // Create a constructor that takes the name and age of the person + // and assigns it to the instance variables + this.name = personname; + this.age= personage; // Create a toString method that gives the name and age of the person diff --git a/src/SetPractice.java b/src/SetPractice.java index d2fc1c9..5dca48d 100644 --- a/src/SetPractice.java +++ b/src/SetPractice.java @@ -1,9 +1,16 @@ +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 schools = new HashSet<>(); // Add 3 elements to the set // (It's OK to do it one-by-one) + schools.add("Green River"); + schools.add("Seattle Central"); + schools.add("lake youngs"); + System.out.println(schools); + // Check whether the Set contains a given String From e2dd0773c1db147f9a604a36cb888e48a693aaec Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 20:22:06 -0700 Subject: [PATCH 26/35] using the contains method , I checked if school name or string is their --- src/SetPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SetPractice.java b/src/SetPractice.java index 5dca48d..725a132 100644 --- a/src/SetPractice.java +++ b/src/SetPractice.java @@ -13,6 +13,7 @@ public static void main(String[] args) { // Check whether the Set contains a given String + System.out.println(schools.contains("Green River")); // Remove an element from the Set From bd834a12fd4d6af87e342619129dcf0900112684 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 20:26:47 -0700 Subject: [PATCH 27/35] used the remove method and for the size, I used size method (shcool.size()) --- src/SetPractice.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SetPractice.java b/src/SetPractice.java index 725a132..6baeb94 100644 --- a/src/SetPractice.java +++ b/src/SetPractice.java @@ -16,8 +16,10 @@ public static void main(String[] args) { System.out.println(schools.contains("Green River")); // Remove an element from the Set + System.out.println(schools.remove("Seattle Central")); // Get the size of the Set + System.out.println(schools.size()); // Iterate over the elements of the Set, printing each one on a separate line From 565dbbf68fcfa9d650a5df3107c767567cb874cb Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 20:29:50 -0700 Subject: [PATCH 28/35] used for loop to print it in each line. --- src/SetPractice.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/SetPractice.java b/src/SetPractice.java index 6baeb94..a452c33 100644 --- a/src/SetPractice.java +++ b/src/SetPractice.java @@ -22,7 +22,9 @@ public static void main(String[] args) { System.out.println(schools.size()); // Iterate over the elements of the Set, printing each one on a separate line - + for (String i : schools){ + System.out.println(i); + } /* * Warning! * From 8eaaff0da167cbf9510da68973aec25ccf555191 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 20:50:26 -0700 Subject: [PATCH 29/35] variable name massage I created string with characters. --- src/StringPractice.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/StringPractice.java b/src/StringPractice.java index 8d87617..188d45c 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -1,7 +1,8 @@ public class StringPractice { public static void main(String[] args) { // Create a string with at least 5 characters and assign it to a variable - + String message = "Struggle Coding"; + System.out.println(message); // Find the length of the string // Concatenate (add) two strings together and reassign the result From 0f8c8f9a580265ff2b1e719a19cf9c642c5af91f Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 20:52:25 -0700 Subject: [PATCH 30/35] found the length of the string which struggle coding --- src/StringPractice.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/StringPractice.java b/src/StringPractice.java index 188d45c..5650220 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -4,9 +4,10 @@ public static void main(String[] args) { String message = "Struggle Coding"; System.out.println(message); // Find the length of the string + System.out.println(message.length()); // Concatenate (add) two strings together and reassign the result - + // Find the value of the character at index 3 // Check whether the string contains a given substring (i.e. does the string have "abc" in it?) From 58e99406ed5b4a8cef0cfbe94ce8fd027736acf7 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 21:01:21 -0700 Subject: [PATCH 31/35] created two strings and then add them or used an addition sign. --- src/StringPractice.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/StringPractice.java b/src/StringPractice.java index 5650220..7f15152 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -7,7 +7,9 @@ public static void main(String[] args) { System.out.println(message.length()); // Concatenate (add) two strings together and reassign the result - + String message1= "Happy"; + String message2= "Friday!"; + System.out.println(message1 +" "+ message2); // Find the value of the character at index 3 // Check whether the string contains a given substring (i.e. does the string have "abc" in it?) From 25b5702d3be1179408beb6dcd08e63c2eef1a72b Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 21:10:04 -0700 Subject: [PATCH 32/35] this string has two p's so it gave me the the first p at index 2. I don't how to assigh the second p --- src/StringPractice.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/StringPractice.java b/src/StringPractice.java index 7f15152..7e8a6c0 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -9,9 +9,11 @@ public static void main(String[] args) { // Concatenate (add) two strings together and reassign the result String message1= "Happy"; String message2= "Friday!"; - System.out.println(message1 +" "+ message2); + String message3 =message1 + message2; + System.out.println(message3); // Find the value of the character at index 3 + System.out.println(message3.indexOf("p")); // Check whether the string contains a given substring (i.e. does the string have "abc" in it?) // Iterate over the characters of the string, printing each one on a separate line From 0f8c87429388d31f950c13a7c9ff0357b087efa4 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 21:14:35 -0700 Subject: [PATCH 33/35] used contains method --- src/StringPractice.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/StringPractice.java b/src/StringPractice.java index 7e8a6c0..59bbfba 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -15,7 +15,7 @@ public static void main(String[] args) { System.out.println(message3.indexOf("p")); // Check whether the string contains a given substring (i.e. does the string have "abc" in it?) - + System.out.println(message3.contains("abc")); // Iterate over the characters of the string, printing each one on a separate line // Create an ArrayList of Strings and assign it to a variable From 7f5b09a949bb97e7ee70f4b861001676aadda6f6 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 21:30:26 -0700 Subject: [PATCH 34/35] I couldn't solve the iterate over the character --- src/StringPractice.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/StringPractice.java b/src/StringPractice.java index 59bbfba..d80e2b8 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 @@ -17,9 +19,12 @@ public static void main(String[] args) { // Check whether the string contains a given substring (i.e. does the string have "abc" in it?) System.out.println(message3.contains("abc")); // Iterate over the characters of the string, printing each one on a separate line - + x = message + message3; + System.out.println(x); + + // Create an ArrayList of Strings and assign it to a variable - + ArrayList colors = new ArrayList<>(); // Add multiple strings to the List (OK to do one-by-one) // Join all of the strings in the list together into a single string separated by commas From 00fee17a1f029982397d63bc009b9a0070566b85 Mon Sep 17 00:00:00 2001 From: Ebtisam Jelani <93232997+Ebtisam0402@users.noreply.github.com> Date: Wed, 1 Oct 2025 21:34:01 -0700 Subject: [PATCH 35/35] created array list of string with an empty list. then added two strings --- src/StringPractice.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/StringPractice.java b/src/StringPractice.java index d80e2b8..528945f 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -26,6 +26,8 @@ public static void main(String[] args) { // Create an ArrayList of Strings and assign it to a variable ArrayList colors = new ArrayList<>(); // Add multiple strings to the List (OK to do one-by-one) + colors.add ("Red"); + colors.add ("Brown"); // 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