diff --git a/src/test/java/api/graphQL/GraphQlTest.java b/src/test/java/apiPractice/graphQL/GraphQlTest.java similarity index 97% rename from src/test/java/api/graphQL/GraphQlTest.java rename to src/test/java/apiPractice/graphQL/GraphQlTest.java index 88966eb..e185a59 100644 --- a/src/test/java/api/graphQL/GraphQlTest.java +++ b/src/test/java/apiPractice/graphQL/GraphQlTest.java @@ -1,4 +1,4 @@ -package api.graphQL; +package apiPractice.graphQL; import static io.restassured.RestAssured.baseURI; import practice.api.graphQL.GraphQlApiObject; diff --git a/src/test/java/api/rest/TAU/dataentities/Location.java b/src/test/java/apiPractice/rest/TAU/dataentities/Location.java similarity index 97% rename from src/test/java/api/rest/TAU/dataentities/Location.java rename to src/test/java/apiPractice/rest/TAU/dataentities/Location.java index a489a22..8bb8616 100644 --- a/src/test/java/api/rest/TAU/dataentities/Location.java +++ b/src/test/java/apiPractice/rest/TAU/dataentities/Location.java @@ -1,4 +1,4 @@ -package api.rest.TAU.dataentities; +package apiPractice.rest.TAU.dataentities; import com.fasterxml.jackson.annotation.*; diff --git a/src/test/java/api/rest/TAU/dataentities/Place.java b/src/test/java/apiPractice/rest/TAU/dataentities/Place.java similarity index 97% rename from src/test/java/api/rest/TAU/dataentities/Place.java rename to src/test/java/apiPractice/rest/TAU/dataentities/Place.java index d99da27..1e43c0c 100644 --- a/src/test/java/api/rest/TAU/dataentities/Place.java +++ b/src/test/java/apiPractice/rest/TAU/dataentities/Place.java @@ -1,4 +1,4 @@ -package api.rest.TAU.dataentities; +package apiPractice.rest.TAU.dataentities; import com.fasterxml.jackson.annotation.*; diff --git a/src/test/java/api/rest/TestAPIs_Booking/ApiTest.java b/src/test/java/apiPractice/rest/TestAPIs_Booking/ApiTest.java similarity index 95% rename from src/test/java/api/rest/TestAPIs_Booking/ApiTest.java rename to src/test/java/apiPractice/rest/TestAPIs_Booking/ApiTest.java index 8c2bebd..43b8b11 100644 --- a/src/test/java/api/rest/TestAPIs_Booking/ApiTest.java +++ b/src/test/java/apiPractice/rest/TestAPIs_Booking/ApiTest.java @@ -1,4 +1,4 @@ -package api.rest.TestAPIs_Booking; +package apiPractice.rest.TestAPIs_Booking; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/api/rest/dataentities/Address.java b/src/test/java/apiPractice/rest/dataentities/Address.java similarity index 96% rename from src/test/java/api/rest/dataentities/Address.java rename to src/test/java/apiPractice/rest/dataentities/Address.java index 52bccd6..0f97551 100644 --- a/src/test/java/api/rest/dataentities/Address.java +++ b/src/test/java/apiPractice/rest/dataentities/Address.java @@ -1,4 +1,4 @@ -package api.rest.dataentities; +package apiPractice.rest.dataentities; public class Address { diff --git a/src/test/java/api/rest/dataentities/Car.java b/src/test/java/apiPractice/rest/dataentities/Car.java similarity index 94% rename from src/test/java/api/rest/dataentities/Car.java rename to src/test/java/apiPractice/rest/dataentities/Car.java index 73e89df..4dba812 100644 --- a/src/test/java/api/rest/dataentities/Car.java +++ b/src/test/java/apiPractice/rest/dataentities/Car.java @@ -1,4 +1,4 @@ -package api.rest.dataentities; +package apiPractice.rest.dataentities; public class Car { diff --git a/src/test/java/api/rest/dataentities/Photo.java b/src/test/java/apiPractice/rest/dataentities/Photo.java similarity index 95% rename from src/test/java/api/rest/dataentities/Photo.java rename to src/test/java/apiPractice/rest/dataentities/Photo.java index 7474ff8..c5ebef9 100644 --- a/src/test/java/api/rest/dataentities/Photo.java +++ b/src/test/java/apiPractice/rest/dataentities/Photo.java @@ -1,4 +1,4 @@ -package api.rest.dataentities; +package apiPractice.rest.dataentities; public class Photo { diff --git a/src/test/java/api/rest/restAssured/DataDrivenDemo.java b/src/test/java/apiPractice/rest/restAssured/DataDrivenDemo.java similarity index 95% rename from src/test/java/api/rest/restAssured/DataDrivenDemo.java rename to src/test/java/apiPractice/rest/restAssured/DataDrivenDemo.java index 81df21a..7af02fd 100644 --- a/src/test/java/api/rest/restAssured/DataDrivenDemo.java +++ b/src/test/java/apiPractice/rest/restAssured/DataDrivenDemo.java @@ -1,4 +1,4 @@ -package api.rest.restAssured; +package apiPractice.rest.restAssured; import io.restassured.RestAssured; import org.testng.annotations.DataProvider; diff --git a/src/test/java/api/rest/restAssured/OptimizingCodeDemo.java b/src/test/java/apiPractice/rest/restAssured/OptimizingCodeDemo.java similarity index 97% rename from src/test/java/api/rest/restAssured/OptimizingCodeDemo.java rename to src/test/java/apiPractice/rest/restAssured/OptimizingCodeDemo.java index c9aadbf..6d30126 100644 --- a/src/test/java/api/rest/restAssured/OptimizingCodeDemo.java +++ b/src/test/java/apiPractice/rest/restAssured/OptimizingCodeDemo.java @@ -1,4 +1,4 @@ -package api.rest.restAssured; +package apiPractice.rest.restAssured; import io.restassured.builder.RequestSpecBuilder; import io.restassured.builder.ResponseSpecBuilder; diff --git a/src/test/java/api/rest/restAssured/RestAssuredDemo.java b/src/test/java/apiPractice/rest/restAssured/RestAssuredDemo.java similarity index 98% rename from src/test/java/api/rest/restAssured/RestAssuredDemo.java rename to src/test/java/apiPractice/rest/restAssured/RestAssuredDemo.java index 2ea1dbd..e7f7155 100644 --- a/src/test/java/api/rest/restAssured/RestAssuredDemo.java +++ b/src/test/java/apiPractice/rest/restAssured/RestAssuredDemo.java @@ -1,4 +1,4 @@ -package api.rest.restAssured; +package apiPractice.rest.restAssured; import io.restassured.RestAssured; import io.restassured.http.ContentType; diff --git a/src/test/java/api/rest/restAssured/RestAssuredPostRequestDemo.java b/src/test/java/apiPractice/rest/restAssured/RestAssuredPostRequestDemo.java similarity index 96% rename from src/test/java/api/rest/restAssured/RestAssuredPostRequestDemo.java rename to src/test/java/apiPractice/rest/restAssured/RestAssuredPostRequestDemo.java index 3320962..f6b0940 100644 --- a/src/test/java/api/rest/restAssured/RestAssuredPostRequestDemo.java +++ b/src/test/java/apiPractice/rest/restAssured/RestAssuredPostRequestDemo.java @@ -1,4 +1,4 @@ -package api.rest.restAssured; +package apiPractice.rest.restAssured; import org.testng.annotations.Test; diff --git a/src/test/java/api/rest/run_script_dataDriven/data_driven.java b/src/test/java/apiPractice/rest/run_script_dataDriven/data_driven.java similarity index 97% rename from src/test/java/api/rest/run_script_dataDriven/data_driven.java rename to src/test/java/apiPractice/rest/run_script_dataDriven/data_driven.java index f12a470..45a7db2 100644 --- a/src/test/java/api/rest/run_script_dataDriven/data_driven.java +++ b/src/test/java/apiPractice/rest/run_script_dataDriven/data_driven.java @@ -1,4 +1,4 @@ -package api.rest.run_script_dataDriven; +package apiPractice.rest.run_script_dataDriven; import static io.restassured.RestAssured.get; diff --git a/src/test/java/api/rest/run_script_dataDriven/read_data.java b/src/test/java/apiPractice/rest/run_script_dataDriven/read_data.java similarity index 95% rename from src/test/java/api/rest/run_script_dataDriven/read_data.java rename to src/test/java/apiPractice/rest/run_script_dataDriven/read_data.java index 5715279..bf8f045 100644 --- a/src/test/java/api/rest/run_script_dataDriven/read_data.java +++ b/src/test/java/apiPractice/rest/run_script_dataDriven/read_data.java @@ -1,4 +1,4 @@ -package api.rest.run_script_dataDriven; +package apiPractice.rest.run_script_dataDriven; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.xssf.usermodel.XSSFRow; diff --git a/src/test/java/api/rest/run_script_jsn/TestCase_json.java b/src/test/java/apiPractice/rest/run_script_jsn/TestCase_json.java similarity index 94% rename from src/test/java/api/rest/run_script_jsn/TestCase_json.java rename to src/test/java/apiPractice/rest/run_script_jsn/TestCase_json.java index d7f3cdc..d0cda83 100644 --- a/src/test/java/api/rest/run_script_jsn/TestCase_json.java +++ b/src/test/java/apiPractice/rest/run_script_jsn/TestCase_json.java @@ -1,4 +1,4 @@ -package api.rest.run_script_jsn; +package apiPractice.rest.run_script_jsn; import static org.hamcrest.Matchers.equalTo; diff --git a/src/test/java/api/rest/saveToFile/Save_API_Response_To_File.java b/src/test/java/apiPractice/rest/saveToFile/Save_API_Response_To_File.java similarity index 96% rename from src/test/java/api/rest/saveToFile/Save_API_Response_To_File.java rename to src/test/java/apiPractice/rest/saveToFile/Save_API_Response_To_File.java index 3cfacc6..9eb7bcc 100644 --- a/src/test/java/api/rest/saveToFile/Save_API_Response_To_File.java +++ b/src/test/java/apiPractice/rest/saveToFile/Save_API_Response_To_File.java @@ -1,4 +1,4 @@ -package api.rest.saveToFile; +package apiPractice.rest.saveToFile; import io.restassured.RestAssured; import org.testng.annotations.Test; diff --git a/src/test/java/api/restAssured/BookingTestApi.java b/src/test/java/apiPractice/restAssured/BookingTestApi.java similarity index 98% rename from src/test/java/api/restAssured/BookingTestApi.java rename to src/test/java/apiPractice/restAssured/BookingTestApi.java index 57d9a6a..582efd1 100644 --- a/src/test/java/api/restAssured/BookingTestApi.java +++ b/src/test/java/apiPractice/restAssured/BookingTestApi.java @@ -1,4 +1,4 @@ -package api.restAssured; +package apiPractice.restAssured; import com.engine.constants.FrameworkConstants; import practice.api.rest.travels.RestApiBase; diff --git a/src/test/java/java/coursesJava/Calculation.java b/src/test/java/java/coursesJava/Calculation.java deleted file mode 100644 index 21d3053..0000000 --- a/src/test/java/java/coursesJava/Calculation.java +++ /dev/null @@ -1,17 +0,0 @@ -package java.coursesJava; - -public class Calculation { - - int total; - - public void addition(int firstNum, int secondNum) { - total = firstNum + secondNum; - System.out.println("The sum of the given numbers: " + total); - } - - public void Subtraction(int firstNum, int secondNum) { - total = firstNum - secondNum; - System.out.println("The difference between the given numbers: " + total); - } - -} diff --git a/src/test/java/java/coursesJava/EnglishCourse.java b/src/test/java/java/coursesJava/EnglishCourse.java deleted file mode 100644 index 79abc0d..0000000 --- a/src/test/java/java/coursesJava/EnglishCourse.java +++ /dev/null @@ -1,16 +0,0 @@ -package java.coursesJava; - -public class EnglishCourse { - - public static void main(String[] args) { - - int students; - int weeks; - int days; - - EnglishCourse EngCourse = new EnglishCourse(); - - - } - -} diff --git a/src/test/java/java/coursesJava/MyCalcuation.java b/src/test/java/java/coursesJava/MyCalcuation.java deleted file mode 100644 index 7c956cb..0000000 --- a/src/test/java/java/coursesJava/MyCalcuation.java +++ /dev/null @@ -1,16 +0,0 @@ -package java.coursesJava; - -public class MyCalcuation extends Calculation { - public void muliplication(int fNum, int secNum) { - total = fNum * secNum; - System.out.println("The prodcut of the given numbers:" + total); - } - - public static void main(String[] args) { - MyCalcuation myCalc = new MyCalcuation(); - myCalc.addition(5, 6); - myCalc.Subtraction(10, 5); - myCalc.muliplication(5, 5); - } - -} diff --git a/src/test/java/java/coursesJava/OperationArithmetic.java b/src/test/java/java/coursesJava/OperationArithmetic.java deleted file mode 100644 index dd52e02..0000000 --- a/src/test/java/java/coursesJava/OperationArithmetic.java +++ /dev/null @@ -1,14 +0,0 @@ -package java.coursesJava; - -public class OperationArithmetic { - - public static void main(String[] args) { - int total; - - total = 4 * 5; - System.out.println("What is 4 times 5? " + total); - - - } - -} diff --git a/src/test/java/java/coursesJava/TestRelational.java b/src/test/java/java/coursesJava/TestRelational.java deleted file mode 100644 index e79fff2..0000000 --- a/src/test/java/java/coursesJava/TestRelational.java +++ /dev/null @@ -1,28 +0,0 @@ -package java.coursesJava; - -public class TestRelational { - - public static void main(String[] args) { - int x = 25, y = 50; - - // == Equal To Operator - System.out.println("Is 25 equal to 50 ? " + (x == y)); - - // != Not Equal To Operator - System.out.println("Is 25 not equal to 50 ? " + (x != y)); - - // > Greater Than Operator - System.out.println("Is 25 greater than 50 ? " + (x > y)); - - // >= Greater Than or equal Operator - System.out.println("Is 25 greater than or equal 50 ? " + (x >= y)); - - // < Less Than Operator - System.out.println("Is 25 Less than 50 ? " + (x < y)); - - // <= Less Than or equal Operator - System.out.println("Is 25 less than or equal 50 ? " + (x <= y)); - - } - -} diff --git a/src/test/java/java/arrays/A_LotteryTicket.java b/src/test/java/javaPractice/arrays/A_LotteryTicket.java similarity index 98% rename from src/test/java/java/arrays/A_LotteryTicket.java rename to src/test/java/javaPractice/arrays/A_LotteryTicket.java index c9b3f9d..5943377 100644 --- a/src/test/java/java/arrays/A_LotteryTicket.java +++ b/src/test/java/javaPractice/arrays/A_LotteryTicket.java @@ -1,4 +1,4 @@ -package java.arrays; +package javaPractice.arrays; import java.util.Arrays; import java.util.Random; diff --git a/src/test/java/java/coursesJava/ArraysDemo.java b/src/test/java/javaPractice/arrays/ArraysDemo.java similarity index 91% rename from src/test/java/java/coursesJava/ArraysDemo.java rename to src/test/java/javaPractice/arrays/ArraysDemo.java index 540a732..685b4e8 100644 --- a/src/test/java/java/coursesJava/ArraysDemo.java +++ b/src/test/java/javaPractice/arrays/ArraysDemo.java @@ -1,4 +1,4 @@ -package java.coursesJava; +package javaPractice.arrays; public class ArraysDemo { public static void main(String[] args) { diff --git a/src/test/java/java/arrays/B_Grades.java b/src/test/java/javaPractice/arrays/B_Grades.java similarity index 98% rename from src/test/java/java/arrays/B_Grades.java rename to src/test/java/javaPractice/arrays/B_Grades.java index 0d03d12..53b3f62 100644 --- a/src/test/java/java/arrays/B_Grades.java +++ b/src/test/java/javaPractice/arrays/B_Grades.java @@ -1,4 +1,4 @@ -package java.arrays; +package javaPractice.arrays; import java.util.Scanner; diff --git a/src/test/java/java/arrays/C_DayOfTheWeek.java b/src/test/java/javaPractice/arrays/C_DayOfTheWeek.java similarity index 94% rename from src/test/java/java/arrays/C_DayOfTheWeek.java rename to src/test/java/javaPractice/arrays/C_DayOfTheWeek.java index 9052831..9083396 100644 --- a/src/test/java/java/arrays/C_DayOfTheWeek.java +++ b/src/test/java/javaPractice/arrays/C_DayOfTheWeek.java @@ -1,4 +1,4 @@ -package java.arrays; +package javaPractice.arrays; import java.util.Scanner; diff --git a/src/test/java/java/coursesJava/DemoArrayList.java b/src/test/java/javaPractice/arrays/DemoArrayList.java similarity index 96% rename from src/test/java/java/coursesJava/DemoArrayList.java rename to src/test/java/javaPractice/arrays/DemoArrayList.java index f3af46d..790afe4 100644 --- a/src/test/java/java/coursesJava/DemoArrayList.java +++ b/src/test/java/javaPractice/arrays/DemoArrayList.java @@ -1,4 +1,4 @@ -package java.coursesJava; +package javaPractice.arrays; import java.util.ArrayList; diff --git a/src/test/java/java/coursesJava/DemoArrayList2.java b/src/test/java/javaPractice/arrays/DemoArrayList2.java similarity index 95% rename from src/test/java/java/coursesJava/DemoArrayList2.java rename to src/test/java/javaPractice/arrays/DemoArrayList2.java index d8ee145..7d11bbb 100644 --- a/src/test/java/java/coursesJava/DemoArrayList2.java +++ b/src/test/java/javaPractice/arrays/DemoArrayList2.java @@ -1,4 +1,4 @@ -package java.coursesJava; +package javaPractice.arrays; import java.util.ArrayList; diff --git a/src/test/java/java/coursesJava/DemoArrayListConcept.java b/src/test/java/javaPractice/arrays/DemoArrayListConcept.java similarity index 96% rename from src/test/java/java/coursesJava/DemoArrayListConcept.java rename to src/test/java/javaPractice/arrays/DemoArrayListConcept.java index 63c1746..798ee9c 100644 --- a/src/test/java/java/coursesJava/DemoArrayListConcept.java +++ b/src/test/java/javaPractice/arrays/DemoArrayListConcept.java @@ -1,4 +1,4 @@ -package java.coursesJava; +package javaPractice.arrays; import java.util.ArrayList; diff --git a/src/test/java/java/coursesJava/StaticArray.java b/src/test/java/javaPractice/arrays/StaticArray.java similarity index 97% rename from src/test/java/java/coursesJava/StaticArray.java rename to src/test/java/javaPractice/arrays/StaticArray.java index aef1791..7fbb074 100644 --- a/src/test/java/java/coursesJava/StaticArray.java +++ b/src/test/java/javaPractice/arrays/StaticArray.java @@ -1,4 +1,4 @@ -package java.coursesJava; +package javaPractice.arrays; public class StaticArray { diff --git a/src/test/java/java/arrays/test.java b/src/test/java/javaPractice/arrays/test.java similarity index 92% rename from src/test/java/java/arrays/test.java rename to src/test/java/javaPractice/arrays/test.java index aeb21f7..5513352 100644 --- a/src/test/java/java/arrays/test.java +++ b/src/test/java/javaPractice/arrays/test.java @@ -1,4 +1,4 @@ -package java.arrays; +package javaPractice.arrays; public class test { public static void main(String[] args) { diff --git a/src/test/java/java/classesAndObjects/A_Method.java b/src/test/java/javaPractice/classesAndObjects/A_Method.java similarity index 93% rename from src/test/java/java/classesAndObjects/A_Method.java rename to src/test/java/javaPractice/classesAndObjects/A_Method.java index 45adf0c..8a32cda 100644 --- a/src/test/java/java/classesAndObjects/A_Method.java +++ b/src/test/java/javaPractice/classesAndObjects/A_Method.java @@ -1,4 +1,4 @@ -package java.classesAndObjects; +package javaPractice.classesAndObjects; import java.util.Scanner; diff --git a/src/test/java/java/classesAndObjects/A_Rectangle.java b/src/test/java/javaPractice/classesAndObjects/A_Rectangle.java similarity index 98% rename from src/test/java/java/classesAndObjects/A_Rectangle.java rename to src/test/java/javaPractice/classesAndObjects/A_Rectangle.java index 8e78744..02c2c8e 100644 --- a/src/test/java/java/classesAndObjects/A_Rectangle.java +++ b/src/test/java/javaPractice/classesAndObjects/A_Rectangle.java @@ -1,4 +1,4 @@ -package java.classesAndObjects; +package javaPractice.classesAndObjects; /* * Objects are structures which contain data in the form of fields and methods. diff --git a/src/test/java/java/classesAndObjects/B_HomeAreaCalculator.java b/src/test/java/javaPractice/classesAndObjects/B_HomeAreaCalculator.java similarity index 97% rename from src/test/java/java/classesAndObjects/B_HomeAreaCalculator.java rename to src/test/java/javaPractice/classesAndObjects/B_HomeAreaCalculator.java index dfacff8..e9980fe 100644 --- a/src/test/java/java/classesAndObjects/B_HomeAreaCalculator.java +++ b/src/test/java/javaPractice/classesAndObjects/B_HomeAreaCalculator.java @@ -1,4 +1,4 @@ -package java.classesAndObjects; +package javaPractice.classesAndObjects; import java.util.Scanner; diff --git a/src/test/java/java/classesAndObjects/B_Variable.java b/src/test/java/javaPractice/classesAndObjects/B_Variable.java similarity index 98% rename from src/test/java/java/classesAndObjects/B_Variable.java rename to src/test/java/javaPractice/classesAndObjects/B_Variable.java index 5f85d6d..108c2b4 100644 --- a/src/test/java/java/classesAndObjects/B_Variable.java +++ b/src/test/java/javaPractice/classesAndObjects/B_Variable.java @@ -1,4 +1,4 @@ -package java.classesAndObjects; +package javaPractice.classesAndObjects; import java.util.Scanner; diff --git a/src/test/java/java/classesAndObjects/C_HomeAreaCalculatorRedo.java b/src/test/java/javaPractice/classesAndObjects/C_HomeAreaCalculatorRedo.java similarity index 96% rename from src/test/java/java/classesAndObjects/C_HomeAreaCalculatorRedo.java rename to src/test/java/javaPractice/classesAndObjects/C_HomeAreaCalculatorRedo.java index d28515f..6d53ea5 100644 --- a/src/test/java/java/classesAndObjects/C_HomeAreaCalculatorRedo.java +++ b/src/test/java/javaPractice/classesAndObjects/C_HomeAreaCalculatorRedo.java @@ -1,4 +1,4 @@ -package java.classesAndObjects; +package javaPractice.classesAndObjects; import java.util.Scanner; diff --git a/src/test/java/java/classesAndObjects/C_Operator.java b/src/test/java/javaPractice/classesAndObjects/C_Operator.java similarity index 98% rename from src/test/java/java/classesAndObjects/C_Operator.java rename to src/test/java/javaPractice/classesAndObjects/C_Operator.java index 4590bb9..8bd01eb 100644 --- a/src/test/java/java/classesAndObjects/C_Operator.java +++ b/src/test/java/javaPractice/classesAndObjects/C_Operator.java @@ -1,4 +1,4 @@ -package java.classesAndObjects; +package javaPractice.classesAndObjects; import java.util.Scanner; diff --git a/src/test/java/java/classesAndObjects/ExceptionHandling.java b/src/test/java/javaPractice/classesAndObjects/ExceptionHandling.java similarity index 97% rename from src/test/java/java/classesAndObjects/ExceptionHandling.java rename to src/test/java/javaPractice/classesAndObjects/ExceptionHandling.java index c3e69ab..67a9c3e 100644 --- a/src/test/java/java/classesAndObjects/ExceptionHandling.java +++ b/src/test/java/javaPractice/classesAndObjects/ExceptionHandling.java @@ -1,4 +1,4 @@ -package java.classesAndObjects; +package javaPractice.classesAndObjects; import java.io.File; import java.io.FileNotFoundException; diff --git a/src/test/java/java/classesAndObjects/GrossPayCalculator.java b/src/test/java/javaPractice/classesAndObjects/GrossPayCalculator.java similarity index 94% rename from src/test/java/java/classesAndObjects/GrossPayCalculator.java rename to src/test/java/javaPractice/classesAndObjects/GrossPayCalculator.java index c287021..f80ecb1 100644 --- a/src/test/java/java/classesAndObjects/GrossPayCalculator.java +++ b/src/test/java/javaPractice/classesAndObjects/GrossPayCalculator.java @@ -1,4 +1,4 @@ -package java.classesAndObjects; +package javaPractice.classesAndObjects; import java.util.Scanner; diff --git a/src/test/java/java/collections/CollectionsDemo.java b/src/test/java/javaPractice/collections/CollectionsDemo.java similarity index 98% rename from src/test/java/java/collections/CollectionsDemo.java rename to src/test/java/javaPractice/collections/CollectionsDemo.java index 919be18..f12b4a1 100644 --- a/src/test/java/java/collections/CollectionsDemo.java +++ b/src/test/java/javaPractice/collections/CollectionsDemo.java @@ -1,4 +1,4 @@ -package java.collections; +package javaPractice.collections; import java.util.*; diff --git a/src/test/java/javaPractice/collections/Comparable/ComparableExample.java b/src/test/java/javaPractice/collections/Comparable/ComparableExample.java new file mode 100644 index 0000000..277ca90 --- /dev/null +++ b/src/test/java/javaPractice/collections/Comparable/ComparableExample.java @@ -0,0 +1,23 @@ +package javaPractice.collections.Comparable; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class ComparableExample { + public static void main(String[] args) { + List employees = new ArrayList<>(); + + employees.add(new Employee(1010, "Rajeev", 100000.00, LocalDate.of(2010, 7, 10))); + employees.add(new Employee(1004, "Chris", 95000.50, LocalDate.of(2017, 3, 19))); + employees.add(new Employee(1015, "David", 134000.00, LocalDate.of(2017, 9, 28))); + + System.out.println("Employees (Before Sorting) : " + employees); + + // This will use the `compareTo()` method of the `Employee` class to compare two employees and sort them. + Collections.sort(employees); + + System.out.println("\nEmployees (After Sorting) : " + employees); + } +} diff --git a/src/test/java/javaPractice/collections/Comparable/ComparatorExample.java b/src/test/java/javaPractice/collections/Comparable/ComparatorExample.java new file mode 100644 index 0000000..a503805 --- /dev/null +++ b/src/test/java/javaPractice/collections/Comparable/ComparatorExample.java @@ -0,0 +1,41 @@ +package javaPractice.collections.Comparable; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +public class ComparatorExample { + public static void main(String[] args) { + List employees = new ArrayList<>(); + + employees.add(new Employee(1010, "Rajeev", 100000.00, LocalDate.of(2010, 7, 10))); + employees.add(new Employee(1004, "Chris", 95000.50, LocalDate.of(2017, 3, 19))); + employees.add(new Employee(1015, "David", 134000.00, LocalDate.of(2017, 9, 28))); + employees.add(new Employee(1009, "Steve", 100000.00, LocalDate.of(2016, 5, 18))); + + System.out.println("Employees : " + employees); + + // Sort employees by Name + Collections.sort(employees, Comparator.comparing(Employee::getName)); + System.out.println("\nEmployees (Sorted by Name) : " + employees); + + // Sort employees by Salary + Collections.sort(employees, Comparator.comparingDouble(Employee::getSalary)); + System.out.println("\nEmployees (Sorted by Salary) : " + employees); + + // Sort employees by JoiningDate + Collections.sort(employees, Comparator.comparing(Employee::getJoiningDate)); + System.out.println("\nEmployees (Sorted by JoiningDate) : " + employees); + + // Sort employees by Name in descending order + Collections.sort(employees, Comparator.comparing(Employee::getName).reversed()); + System.out.println("\nEmployees (Sorted by Name in descending order) : " + employees); + + // Chaining multiple Comparators + // Sort by Salary. If Salary is same then sort by Name + Collections.sort(employees, Comparator.comparingDouble(Employee::getSalary).thenComparing(Employee::getName)); + System.out.println("\nEmployees (Sorted by Salary and Name) : " + employees); + } +} \ No newline at end of file diff --git a/src/test/java/javaPractice/collections/Comparable/Employee.java b/src/test/java/javaPractice/collections/Comparable/Employee.java new file mode 100644 index 0000000..51e9013 --- /dev/null +++ b/src/test/java/javaPractice/collections/Comparable/Employee.java @@ -0,0 +1,86 @@ +package javaPractice.collections.Comparable; + +import java.time.LocalDate; +import java.util.Objects; + +class Employee implements Comparable { + private int id; + private String name; + private double salary; + private LocalDate joiningDate; + + public Employee(int id, String name, double salary, LocalDate joiningDate) { + this.id = id; + this.name = name; + this.salary = salary; + this.joiningDate = joiningDate; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getSalary() { + return salary; + } + + public void setSalary(double salary) { + this.salary = salary; + } + + public LocalDate getJoiningDate() { + return joiningDate; + } + + public void setJoiningDate(LocalDate joiningDate) { + this.joiningDate = joiningDate; + } + + // Compare Two Employees based on their ID + + /** + * @param anotherEmployee - The Employee to be compared. + * @return A negative integer, zero, or a positive integer as this employee + * is less than, equal to, or greater than the supplied employee object. + */ + @Override + public int compareTo(Employee anotherEmployee) { + return this.getId() - anotherEmployee.getId(); + } + + // Two employees are equal if their IDs are equal + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Employee employee = (Employee) o; + return id == employee.id; + } + + @Override + public int hashCode() { + return Objects.hash(id); + } + + @Override + public String toString() { + return "Employee{" + + "id=" + id + + ", name='" + name + '\'' + + ", salary=" + salary + + ", joiningDate=" + joiningDate + + '}'; + } +} \ No newline at end of file diff --git a/src/test/java/javaPractice/collections/Readme.md b/src/test/java/javaPractice/collections/Readme.md new file mode 100644 index 0000000..35a0dab --- /dev/null +++ b/src/test/java/javaPractice/collections/Readme.md @@ -0,0 +1,23 @@ +## Java Collections Framework Tutorials with Simple Examples + +1. [Java ArrayList Tutorial with Examples](https://www.callicoder.com/java-arraylist/) + +2. [Java LinkedList Tutorial with Examples](https://www.callicoder.com/java-linkedlist/) + +3. [Java HashMap Tutorial with Examples](https://www.callicoder.com/java-hashmap/) + +4. [Java LinkedHashMap Tutorial with Examples](https://www.callicoder.com/java-linkedhashmap/) + +5. [Java TreeMap Tutorial with Examples](https://www.callicoder.com/java-treemap/) + +6. [Java HashSet Tutorial with Examples](https://www.callicoder.com/java-hashset/) + +7. [Java TreeSet Tutorial with Examples](https://www.callicoder.com/java-treeset/) + +8. [Java Stack Class Tutorial with Examples](https://www.callicoder.com/java-stack/) + +9. [Java Queue Interface Tutorial with Examples](https://www.callicoder.com/java-queue/) + +10. [Java Priority Queue Tutorial with Examples](https://www.callicoder.com/java-priority-queue/) + +11. [Java Comparable and Comparator interface Examples](https://www.callicoder.com/java-comparable-comparator/) \ No newline at end of file diff --git a/src/test/java/javaPractice/collections/arrayList/AccessElementsFromArrayListExample.java b/src/test/java/javaPractice/collections/arrayList/AccessElementsFromArrayListExample.java new file mode 100644 index 0000000..aef7b3b --- /dev/null +++ b/src/test/java/javaPractice/collections/arrayList/AccessElementsFromArrayListExample.java @@ -0,0 +1,36 @@ +package javaPractice.collections.arrayList; + +import java.util.ArrayList; +import java.util.List; + +public class AccessElementsFromArrayListExample { + public static void main(String[] args) { + List topCompanies = new ArrayList<>(); + + // Check if an ArrayList is empty + System.out.println("Is the topCompanies list empty? : " + topCompanies.isEmpty()); + + topCompanies.add("Google"); + topCompanies.add("Apple"); + topCompanies.add("Microsoft"); + topCompanies.add("Amazon"); + topCompanies.add("Facebook"); + + // Find the size of an ArrayList + System.out.println("Here are the top " + topCompanies.size() + " companies in the world"); + System.out.println(topCompanies); + + // Retrieve the element at a given index + String bestCompany = topCompanies.get(0); + String secondBestCompany = topCompanies.get(1); + String lastCompany = topCompanies.get(topCompanies.size() - 1); + + System.out.println("Best Company: " + bestCompany); + System.out.println("Second Best Company: " + secondBestCompany); + System.out.println("Last Company in the list: " + lastCompany); + + // Modify the element at a given index + topCompanies.set(4, "Walmart"); + System.out.println("Modified top companies list: " + topCompanies); + } +} diff --git a/src/test/java/javaPractice/collections/arrayList/ArrayListCollectionsSortExample.java b/src/test/java/javaPractice/collections/arrayList/ArrayListCollectionsSortExample.java new file mode 100644 index 0000000..4b2972f --- /dev/null +++ b/src/test/java/javaPractice/collections/arrayList/ArrayListCollectionsSortExample.java @@ -0,0 +1,23 @@ +package javaPractice.collections.arrayList; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class ArrayListCollectionsSortExample { + public static void main(String[] args) { + List numbers = new ArrayList<>(); + numbers.add(13); + numbers.add(7); + numbers.add(18); + numbers.add(5); + numbers.add(2); + + System.out.println("Before : " + numbers); + + // Sorting an ArrayList using Collections.sort() method + Collections.sort(numbers); + + System.out.println("After : " + numbers); + } +} diff --git a/src/test/java/javaPractice/collections/arrayList/ArrayListIteratorRemoveExample.java b/src/test/java/javaPractice/collections/arrayList/ArrayListIteratorRemoveExample.java new file mode 100644 index 0000000..901ed75 --- /dev/null +++ b/src/test/java/javaPractice/collections/arrayList/ArrayListIteratorRemoveExample.java @@ -0,0 +1,25 @@ +package javaPractice.collections.arrayList; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class ArrayListIteratorRemoveExample { + public static void main(String[] args) { + List numbers = new ArrayList<>(); + numbers.add(13); + numbers.add(18); + numbers.add(25); + numbers.add(40); + + Iterator numbersIterator = numbers.iterator(); + while (numbersIterator.hasNext()) { + Integer num = numbersIterator.next(); + if (num % 2 != 0) { + numbersIterator.remove(); + } + } + + System.out.println(numbers); + } +} diff --git a/src/test/java/javaPractice/collections/arrayList/ArrayListObjectSortExample.java b/src/test/java/javaPractice/collections/arrayList/ArrayListObjectSortExample.java new file mode 100644 index 0000000..23b2aa2 --- /dev/null +++ b/src/test/java/javaPractice/collections/arrayList/ArrayListObjectSortExample.java @@ -0,0 +1,66 @@ +package javaPractice.collections.arrayList; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +class Person { + private String name; + private Integer age; + + public Person(String name, Integer age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } + + @Override + public String toString() { + return "{" + + "name='" + name + '\'' + + ", age=" + age + + '}'; + } +} + +public class ArrayListObjectSortExample { + public static void main(String[] args) { + List people = new ArrayList<>(); + people.add(new Person("Sachin", 47)); + people.add(new Person("Chris", 34)); + people.add(new Person("Rajeev", 25)); + people.add(new Person("David", 31)); + + System.out.println("Person List : " + people); + + // Sort People by their Age + people.sort((person1, person2) -> { + return person1.getAge() - person2.getAge(); + }); + + // A more concise way of writing the above sorting function + people.sort(Comparator.comparingInt(Person::getAge)); + + System.out.println("Sorted Person List by Age : " + people); + + // You can also sort using Collections.sort() method by passing the custom Comparator + Collections.sort(people, Comparator.comparing(Person::getName)); + System.out.println("Sorted Person List by Name : " + people); + } +} diff --git a/src/test/java/javaPractice/collections/arrayList/ArrayListSortExample.java b/src/test/java/javaPractice/collections/arrayList/ArrayListSortExample.java new file mode 100644 index 0000000..5acaae3 --- /dev/null +++ b/src/test/java/javaPractice/collections/arrayList/ArrayListSortExample.java @@ -0,0 +1,33 @@ +package javaPractice.collections.arrayList; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + +public class ArrayListSortExample { + public static void main(String[] args) { + List names = new ArrayList<>(); + names.add("Lisa"); + names.add("Jennifer"); + names.add("Mark"); + names.add("David"); + + System.out.println("Names : " + names); + + // Sort an ArrayList using its sort() method. You must pass a Comparator to the ArrayList.sort() method. + names.sort(new Comparator() { + @Override + public int compare(String name1, String name2) { + return name1.compareTo(name2); + } + }); + + // The above `sort()` method call can also be written simply using lambda expression + names.sort((name1, name2) -> name1.compareTo(name2)); + + // Following is an even more concise solution + names.sort(Comparator.naturalOrder()); + + System.out.println("Sorted Names : " + names); + } +} diff --git a/src/test/java/javaPractice/collections/arrayList/ArrayListUserDefinedObjectExample.java b/src/test/java/javaPractice/collections/arrayList/ArrayListUserDefinedObjectExample.java new file mode 100644 index 0000000..ebb46ae --- /dev/null +++ b/src/test/java/javaPractice/collections/arrayList/ArrayListUserDefinedObjectExample.java @@ -0,0 +1,43 @@ +package javaPractice.collections.arrayList; + +import java.util.ArrayList; +import java.util.List; + +class User { + private String name; + private int age; + + public User(String name, int age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } +} + +public class ArrayListUserDefinedObjectExample { + public static void main(String[] args) { + List users = new ArrayList<>(); + users.add(new User("Rajeev", 25)); + users.add(new User("John", 34)); + users.add(new User("Steve", 29)); + + users.forEach(user -> { + System.out.println("Name : " + user.getName() + ", Age : " + user.getAge()); + }); + } +} diff --git a/src/test/java/javaPractice/collections/arrayList/CreateArrayListExample.java b/src/test/java/javaPractice/collections/arrayList/CreateArrayListExample.java new file mode 100644 index 0000000..fd9b4c4 --- /dev/null +++ b/src/test/java/javaPractice/collections/arrayList/CreateArrayListExample.java @@ -0,0 +1,25 @@ +package javaPractice.collections.arrayList; + +import java.util.ArrayList; +import java.util.List; + +public class CreateArrayListExample { + + public static void main(String[] args) { + // Creating an ArrayList of String using + List animals = new ArrayList<>(); + + // Adding new elements to the ArrayList + animals.add("Lion"); + animals.add("Tiger"); + animals.add("Cat"); + animals.add("Dog"); + + System.out.println(animals); + + // Adding an element at a particular index in an ArrayList + animals.add(2, "Elephant"); + + System.out.println(animals); + } +} \ No newline at end of file diff --git a/src/test/java/javaPractice/collections/arrayList/CreateArrayListFromCollectionExample.java b/src/test/java/javaPractice/collections/arrayList/CreateArrayListFromCollectionExample.java new file mode 100644 index 0000000..c5bcb47 --- /dev/null +++ b/src/test/java/javaPractice/collections/arrayList/CreateArrayListFromCollectionExample.java @@ -0,0 +1,32 @@ +package javaPractice.collections.arrayList; + +import java.util.ArrayList; +import java.util.List; + +public class CreateArrayListFromCollectionExample { + + public static void main(String[] args) { + List firstFivePrimeNumbers = new ArrayList<>(); + firstFivePrimeNumbers.add(2); + firstFivePrimeNumbers.add(3); + firstFivePrimeNumbers.add(5); + firstFivePrimeNumbers.add(7); + firstFivePrimeNumbers.add(11); + + // Creating an ArrayList from another collection + List firstTenPrimeNumbers = new ArrayList<>(firstFivePrimeNumbers); + + + List nextFivePrimeNumbers = new ArrayList<>(); + nextFivePrimeNumbers.add(13); + nextFivePrimeNumbers.add(17); + nextFivePrimeNumbers.add(19); + nextFivePrimeNumbers.add(23); + nextFivePrimeNumbers.add(29); + + // Adding an entire collection to an ArrayList + firstTenPrimeNumbers.addAll(nextFivePrimeNumbers); + + System.out.println(firstTenPrimeNumbers); + } +} diff --git a/src/test/java/javaPractice/collections/arrayList/IterateOverArrayListExample.java b/src/test/java/javaPractice/collections/arrayList/IterateOverArrayListExample.java new file mode 100644 index 0000000..933ea5e --- /dev/null +++ b/src/test/java/javaPractice/collections/arrayList/IterateOverArrayListExample.java @@ -0,0 +1,52 @@ +package javaPractice.collections.arrayList; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; + +public class IterateOverArrayListExample { + public static void main(String[] args) { + List tvShows = new ArrayList<>(); + tvShows.add("Breaking Bad"); + tvShows.add("Game Of Thrones"); + tvShows.add("Friends"); + tvShows.add("Prison break"); + + System.out.println("=== Iterate using Java 8 forEach and lambda ==="); + tvShows.forEach(tvShow -> { + System.out.println(tvShow); + }); + + System.out.println("\n=== Iterate using an iterator() ==="); + Iterator tvShowIterator = tvShows.iterator(); + while (tvShowIterator.hasNext()) { + String tvShow = tvShowIterator.next(); + System.out.println(tvShow); + } + + System.out.println("\n=== Iterate using an iterator() and Java 8 forEachRemaining() method ==="); + tvShowIterator = tvShows.iterator(); + tvShowIterator.forEachRemaining(tvShow -> { + System.out.println(tvShow); + }); + + System.out.println("\n=== Iterate using a listIterator() to traverse in both directions ==="); + // Here, we start from the end of the list and traverse backwards. + ListIterator tvShowListIterator = tvShows.listIterator(tvShows.size()); + while (tvShowListIterator.hasPrevious()) { + String tvShow = tvShowListIterator.previous(); + System.out.println(tvShow); + } + + System.out.println("\n=== Iterate using simple for-each loop ==="); + for (String tvShow : tvShows) { + System.out.println(tvShow); + } + + System.out.println("\n=== Iterate using for loop with index ==="); + for (int i = 0; i < tvShows.size(); i++) { + System.out.println(tvShows.get(i)); + } + } +} diff --git a/src/test/java/javaPractice/collections/arrayList/RemoveElementsFromArrayListExample.java b/src/test/java/javaPractice/collections/arrayList/RemoveElementsFromArrayListExample.java new file mode 100644 index 0000000..17b2643 --- /dev/null +++ b/src/test/java/javaPractice/collections/arrayList/RemoveElementsFromArrayListExample.java @@ -0,0 +1,57 @@ +package javaPractice.collections.arrayList; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Predicate; + +public class RemoveElementsFromArrayListExample { + public static void main(String[] args) { + List programmingLanguages = new ArrayList<>(); + programmingLanguages.add("C"); + programmingLanguages.add("C++"); + programmingLanguages.add("Java"); + programmingLanguages.add("Kotlin"); + programmingLanguages.add("Python"); + programmingLanguages.add("Perl"); + programmingLanguages.add("Ruby"); + + System.out.println("Initial List: " + programmingLanguages); + + // Remove the element at index `5` + programmingLanguages.remove(5); + System.out.println("After remove(5): " + programmingLanguages); + + // Remove the first occurrence of the given element from the ArrayList + // (The remove() method returns false if the element does not exist in the ArrayList) + boolean isRemoved = programmingLanguages.remove("Kotlin"); + System.out.println("After remove(\"Kotlin\"): " + programmingLanguages); + + // Remove all the elements that exist in a given collection + List scriptingLanguages = new ArrayList<>(); + scriptingLanguages.add("Python"); + scriptingLanguages.add("Ruby"); + scriptingLanguages.add("Perl"); + + programmingLanguages.removeAll(scriptingLanguages); + System.out.println("After removeAll(scriptingLanguages): " + programmingLanguages); + + // Remove if the element matches a given predicate + programmingLanguages.removeIf(new Predicate() { + @Override + public boolean test(String s) { + return s.startsWith("C"); + } + }); + + /* + The above removeIf() call can also be written using lambda expression like this - + programmingLanguages.removeIf(s -> s.startsWith("C")) + */ + + System.out.println("After Removing all elements that start with \"C\": " + programmingLanguages); + + // Remove all elements from the ArrayList + programmingLanguages.clear(); + System.out.println("After clear(): " + programmingLanguages); + } +} diff --git a/src/test/java/javaPractice/collections/arrayList/SearchElementsInArrayListExample.java b/src/test/java/javaPractice/collections/arrayList/SearchElementsInArrayListExample.java new file mode 100644 index 0000000..254d2c9 --- /dev/null +++ b/src/test/java/javaPractice/collections/arrayList/SearchElementsInArrayListExample.java @@ -0,0 +1,28 @@ +package javaPractice.collections.arrayList; + +import java.util.ArrayList; +import java.util.List; + +public class SearchElementsInArrayListExample { + public static void main(String[] args) { + List names = new ArrayList<>(); + names.add("John"); + names.add("Alice"); + names.add("Bob"); + names.add("Steve"); + names.add("John"); + names.add("Steve"); + names.add("Maria"); + + // Check if an ArrayList contains a given element + System.out.println("Does names array contain \"Bob\"? : " + names.contains("Bob")); + + // Find the index of the first occurrence of an element in an ArrayList + System.out.println("indexOf \"Steve\": " + names.indexOf("Steve")); + System.out.println("indexOf \"Mark\": " + names.indexOf("Mark")); + + // Find the index of the last occurrence of an element in an ArrayList + System.out.println("lastIndexOf \"John\" : " + names.lastIndexOf("John")); + System.out.println("lastIndexOf \"Bill\" : " + names.lastIndexOf("Bill")); + } +} diff --git a/src/test/java/javaPractice/collections/arrayList/SynchronizedArrayListExample.java b/src/test/java/javaPractice/collections/arrayList/SynchronizedArrayListExample.java new file mode 100644 index 0000000..09b515e --- /dev/null +++ b/src/test/java/javaPractice/collections/arrayList/SynchronizedArrayListExample.java @@ -0,0 +1,46 @@ +package javaPractice.collections.arrayList; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +public class SynchronizedArrayListExample { + public static void main(String[] args) throws InterruptedException { + List safeArrayList = Collections.synchronizedList(new ArrayList<>()); + safeArrayList.add(1); + safeArrayList.add(2); + safeArrayList.add(3); + + // Create a thread pool of size 10 + ExecutorService executorService = Executors.newFixedThreadPool(10); + + // Create a Runnable task that increments each element of the ArrayList by one + Runnable task = () -> { + incrementArrayList(safeArrayList); + }; + + // Submit the task to the executor service 100 times. + // All the tasks will modify the ArrayList concurrently + for (int i = 0; i < 100; i++) { + executorService.submit(task); + } + + executorService.shutdown(); + executorService.awaitTermination(60, TimeUnit.SECONDS); + + System.out.println(safeArrayList); + } + + // Increment all the values in the ArrayList by one + private static void incrementArrayList(List safeArrayList) { + synchronized (safeArrayList) { + for (int i = 0; i < safeArrayList.size(); i++) { + Integer value = safeArrayList.get(i); + safeArrayList.set(i, value + 1); + } + } + } +} diff --git a/src/test/java/javaPractice/collections/arrayList/UnsafeArrayListExample.java b/src/test/java/javaPractice/collections/arrayList/UnsafeArrayListExample.java new file mode 100644 index 0000000..5e5e73c --- /dev/null +++ b/src/test/java/javaPractice/collections/arrayList/UnsafeArrayListExample.java @@ -0,0 +1,43 @@ +package javaPractice.collections.arrayList; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +public class UnsafeArrayListExample { + public static void main(String[] args) throws InterruptedException { + List unsafeArrayList = new ArrayList<>(); + unsafeArrayList.add(1); + unsafeArrayList.add(2); + unsafeArrayList.add(3); + + // Create a thread pool of size 10 + ExecutorService executorService = Executors.newFixedThreadPool(10); + + // Create a Runnable task that increments each element of the ArrayList by one + Runnable task = () -> { + incrementArrayList(unsafeArrayList); + }; + + // Submit the task to the executor service 100 times. + // All the tasks will modify the ArrayList concurrently + for (int i = 0; i < 100; i++) { + executorService.submit(task); + } + + executorService.shutdown(); + executorService.awaitTermination(60, TimeUnit.SECONDS); + + System.out.println(unsafeArrayList); + } + + // Increment all the values in the ArrayList by one + private static void incrementArrayList(List unsafeArrayList) { + for (int i = 0; i < unsafeArrayList.size(); i++) { + Integer value = unsafeArrayList.get(i); + unsafeArrayList.set(i, value + 1); + } + } +} diff --git a/src/test/java/javaPractice/collections/hashMap/AccessKeysFromHashMapExample.java b/src/test/java/javaPractice/collections/hashMap/AccessKeysFromHashMapExample.java new file mode 100644 index 0000000..5c847f0 --- /dev/null +++ b/src/test/java/javaPractice/collections/hashMap/AccessKeysFromHashMapExample.java @@ -0,0 +1,47 @@ +package javaPractice.collections.hashMap; + +import java.util.HashMap; +import java.util.Map; + +public class AccessKeysFromHashMapExample { + public static void main(String[] args) { + Map userCityMapping = new HashMap<>(); + + // Check if a HashMap is empty + System.out.println("is userCityMapping empty? : " + userCityMapping.isEmpty()); + + userCityMapping.put("John", "New York"); + userCityMapping.put("Rajeev", "Bengaluru"); + userCityMapping.put("Steve", "London"); + + System.out.println("userCityMapping HashMap : " + userCityMapping); + + // Find the size of a HashMap + System.out.println("We have the city information of " + userCityMapping.size() + " users"); + + String userName = "Steve"; + // Check if a key exists in the HashMap + if (userCityMapping.containsKey(userName)) { + // Get the value assigned to a given key in the HashMap + String city = userCityMapping.get(userName); + System.out.println(userName + " lives in " + city); + } else { + System.out.println("City details not found for user " + userName); + } + + // Check if a value exists in a HashMap + if (userCityMapping.containsValue("New York")) { + System.out.println("There is a user in the userCityMapping who lives in New York"); + } else { + System.out.println("There is not user in the userCityMapping who lives in New York"); + } + + + // Modify the value assigned to an existing key + userCityMapping.put(userName, "California"); + System.out.println(userName + " moved to a new city " + userCityMapping.get(userName) + ", New userCityMapping : " + userCityMapping); + + // The get() method returns `null` if the specified key was not found in the HashMap + System.out.println("Lisa's city : " + userCityMapping.get("Lisa")); + } +} diff --git a/src/test/java/javaPractice/collections/hashMap/CreateHashMapExample.java b/src/test/java/javaPractice/collections/hashMap/CreateHashMapExample.java new file mode 100644 index 0000000..41ecf71 --- /dev/null +++ b/src/test/java/javaPractice/collections/hashMap/CreateHashMapExample.java @@ -0,0 +1,21 @@ +package javaPractice.collections.hashMap; + +import java.util.HashMap; +import java.util.Map; + +public class CreateHashMapExample { + public static void main(String[] args) { + // Creating a HashMap + Map numberMapping = new HashMap<>(); + + // Adding key-value pairs to a HashMap + numberMapping.put("One", 1); + numberMapping.put("Two", 2); + numberMapping.put("Three", 3); + + // Add a new key-value pair only if the key does not exist in the HashMap, or is mapped to `null` + numberMapping.putIfAbsent("Four", 4); + + System.out.println(numberMapping); + } +} diff --git a/src/test/java/javaPractice/collections/hashMap/HashMapEntryKeySetValuesExample.java b/src/test/java/javaPractice/collections/hashMap/HashMapEntryKeySetValuesExample.java new file mode 100644 index 0000000..2e69f74 --- /dev/null +++ b/src/test/java/javaPractice/collections/hashMap/HashMapEntryKeySetValuesExample.java @@ -0,0 +1,30 @@ +package javaPractice.collections.hashMap; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +public class HashMapEntryKeySetValuesExample { + public static void main(String[] args) { + Map countryISOCodeMapping = new HashMap<>(); + + countryISOCodeMapping.put("India", "IN"); + countryISOCodeMapping.put("United States of America", "US"); + countryISOCodeMapping.put("Russia", "RU"); + countryISOCodeMapping.put("Japan", "JP"); + countryISOCodeMapping.put("China", "CN"); + + // HashMap's entry set + Set> countryISOCodeEntries = countryISOCodeMapping.entrySet(); + System.out.println("countryISOCode entries : " + countryISOCodeEntries); + + // HashMap's key set + Set countries = countryISOCodeMapping.keySet(); + System.out.println("countries : " + countries); + + // HashMap's values + Collection isoCodes = countryISOCodeMapping.values(); + System.out.println("isoCodes : " + isoCodes); + } +} diff --git a/src/test/java/javaPractice/collections/hashMap/HashMapUserDefinedObjectExample.java b/src/test/java/javaPractice/collections/hashMap/HashMapUserDefinedObjectExample.java new file mode 100644 index 0000000..f3fa99d --- /dev/null +++ b/src/test/java/javaPractice/collections/hashMap/HashMapUserDefinedObjectExample.java @@ -0,0 +1,60 @@ +package javaPractice.collections.hashMap; + +import java.util.HashMap; +import java.util.Map; + +class Employee { + private Integer id; + private String name; + private String city; + + public Employee(Integer id, String name, String city) { + this.id = id; + this.name = name; + this.city = city; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + @Override + public String toString() { + return "Employee{" + + "name='" + name + '\'' + + ", city='" + city + '\'' + + '}'; + } +} + +public class HashMapUserDefinedObjectExample { + public static void main(String[] args) { + + Map employeesMap = new HashMap<>(); + employeesMap.put(1001, new Employee(1001, "Rajeev", "Bengaluru")); + employeesMap.put(1002, new Employee(1002, "David", "New York")); + employeesMap.put(1003, new Employee(1003, "Jack", "Paris")); + + System.out.println(employeesMap); + } +} diff --git a/src/test/java/javaPractice/collections/hashMap/IterateOverHashMap.java b/src/test/java/javaPractice/collections/hashMap/IterateOverHashMap.java new file mode 100644 index 0000000..39073a5 --- /dev/null +++ b/src/test/java/javaPractice/collections/hashMap/IterateOverHashMap.java @@ -0,0 +1,44 @@ +package javaPractice.collections.hashMap; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +public class IterateOverHashMap { + public static void main(String[] args) { + Map employeeSalary = new HashMap<>(); + employeeSalary.put("David", 76000.00); + employeeSalary.put("John", 120000.00); + employeeSalary.put("Mark", 95000.00); + employeeSalary.put("Steven", 134000.00); + + System.out.println("=== Iterating over a HashMap using Java 8 forEach and lambda ==="); + employeeSalary.forEach((employee, salary) -> { + System.out.println(employee + " => " + salary); + }); + + System.out.println("\n=== Iterating over the HashMap's entrySet using iterator() ==="); + Set> employeeSalaryEntries = employeeSalary.entrySet(); + Iterator> employeeSalaryIterator = employeeSalaryEntries.iterator(); + while (employeeSalaryIterator.hasNext()) { + Map.Entry entry = employeeSalaryIterator.next(); + System.out.println(entry.getKey() + " => " + entry.getValue()); + } + + System.out.println("\n=== Iterating over the HashMap's entrySet using Java 8 forEach and lambda ==="); + employeeSalary.entrySet().forEach(entry -> { + System.out.println(entry.getKey() + " => " + entry.getValue()); + }); + + System.out.println("\n=== Iterating over the HashMap's entrySet using simple for-each loop ==="); + for (Map.Entry entry : employeeSalary.entrySet()) { + System.out.println(entry.getKey() + " => " + entry.getValue()); + } + + System.out.println("\n=== Iterating over the HashMap's keySet ==="); + employeeSalary.keySet().forEach(employee -> { + System.out.println(employee + " => " + employeeSalary.get(employee)); + }); + } +} diff --git a/src/test/java/javaPractice/collections/hashMap/RemoveKeysFromHashMapExample.java b/src/test/java/javaPractice/collections/hashMap/RemoveKeysFromHashMapExample.java new file mode 100644 index 0000000..0793eeb --- /dev/null +++ b/src/test/java/javaPractice/collections/hashMap/RemoveKeysFromHashMapExample.java @@ -0,0 +1,36 @@ +package javaPractice.collections.hashMap; + +import java.util.HashMap; +import java.util.Map; + +public class RemoveKeysFromHashMapExample { + public static void main(String[] args) { + Map husbandWifeMapping = new HashMap<>(); + husbandWifeMapping.put("Jack", "Marie"); + husbandWifeMapping.put("Chris", "Lisa"); + husbandWifeMapping.put("Steve", "Jennifer"); + + System.out.println("Husband-Wife Mapping : " + husbandWifeMapping); + + // Remove a key from the HashMap + // Ex - Unfortunately, Chris got divorced. Let's remove him from the mapping + String husband = "Chris"; + String wife = husbandWifeMapping.remove(husband); + + System.out.println("Couple (" + husband + " => " + wife + ") got divorced"); + System.out.println("New Mapping : " + husbandWifeMapping); + + // Remove a key from the HashMap only if it is mapped to the given value + // Ex - Divorce "Jack" only if He is married to "Linda" + boolean isRemoved = husbandWifeMapping.remove("Jack", "Linda"); + System.out.println("Did Jack get removed from the mapping? : " + isRemoved); + + // remove() returns null if the mapping was not found for the supplied key + wife = husbandWifeMapping.remove("David"); + if (wife == null) { + System.out.println("Looks like David is not married to anyone"); + } else { + System.out.println("Removed David and his wife from the mapping"); + } + } +} diff --git a/src/test/java/javaPractice/collections/hashMap/SynchronizedHashMapExample.java b/src/test/java/javaPractice/collections/hashMap/SynchronizedHashMapExample.java new file mode 100644 index 0000000..6c07199 --- /dev/null +++ b/src/test/java/javaPractice/collections/hashMap/SynchronizedHashMapExample.java @@ -0,0 +1,42 @@ +package javaPractice.collections.hashMap; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +public class SynchronizedHashMapExample { + public static void main(String[] args) throws InterruptedException { + Map cricketTeamScore = Collections.synchronizedMap(new HashMap<>()); + cricketTeamScore.put("Australia", 349); + cricketTeamScore.put("India", 250); + + // Create an ExecutorService with a Thread Pool of size 10 + ExecutorService executorService = Executors.newFixedThreadPool(10); + + // Create a Runnable object that increments the value associated with a given key in the HashMap by one. + Runnable task = () -> { + incrementTeamScore(cricketTeamScore, "India"); + }; + + // Submit the Runnable object to the executorService 100 times to test concurrent modifications + for (int i = 0; i < 100; i++) { + executorService.submit(task); + } + + executorService.shutdown(); + executorService.awaitTermination(60, TimeUnit.SECONDS); + + System.out.println("Final Score of Team India : " + cricketTeamScore.get("India")); + } + + // Increment the score of a team by one + private static void incrementTeamScore(Map cricketTeamScore, String team) { + synchronized (cricketTeamScore) { + Integer score = cricketTeamScore.get(team); + cricketTeamScore.put(team, score + 1); + } + } +} diff --git a/src/test/java/javaPractice/collections/hashMap/UnsafeHashMapExample.java b/src/test/java/javaPractice/collections/hashMap/UnsafeHashMapExample.java new file mode 100644 index 0000000..7af7db8 --- /dev/null +++ b/src/test/java/javaPractice/collections/hashMap/UnsafeHashMapExample.java @@ -0,0 +1,39 @@ +package javaPractice.collections.hashMap; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +public class UnsafeHashMapExample { + public static void main(String[] args) throws InterruptedException { + Map cricketTeamScore = new HashMap<>(); + cricketTeamScore.put("Australia", 349); + cricketTeamScore.put("India", 250); + + // Create an ExecutorService with a Thread Pool of size 10 + ExecutorService executorService = Executors.newFixedThreadPool(10); + + // Create a Runnable object that increments the value associated with a given key in the HashMap by one. + Runnable task = () -> { + incrementTeamScore(cricketTeamScore, "India"); + }; + + // Submit the Runnable object to the executorService 100 times to test concurrent modifications + for (int i = 0; i < 100; i++) { + executorService.submit(task); + } + + executorService.shutdown(); + executorService.awaitTermination(60, TimeUnit.SECONDS); + + System.out.println("Final Score of Team India : " + cricketTeamScore.get("India")); + } + + // Increment the score of a team by one + private static void incrementTeamScore(Map cricketTeamScore, String team) { + Integer score = cricketTeamScore.get(team); + cricketTeamScore.put(team, score + 1); + } +} diff --git a/src/test/java/javaPractice/collections/hashSet/CreateHashSetExample.java b/src/test/java/javaPractice/collections/hashSet/CreateHashSetExample.java new file mode 100644 index 0000000..89c88f1 --- /dev/null +++ b/src/test/java/javaPractice/collections/hashSet/CreateHashSetExample.java @@ -0,0 +1,25 @@ +package javaPractice.collections.hashSet; + +import java.util.HashSet; +import java.util.Set; + +public class CreateHashSetExample { + public static void main(String[] args) { + // Creating a HashSet + Set daysOfWeek = new HashSet<>(); + + // Adding new elements to the HashSet + daysOfWeek.add("Monday"); + daysOfWeek.add("Tuesday"); + daysOfWeek.add("Wednesday"); + daysOfWeek.add("Thursday"); + daysOfWeek.add("Friday"); + daysOfWeek.add("Saturday"); + daysOfWeek.add("Sunday"); + + // Adding duplicate elements will be ignored + daysOfWeek.add("Monday"); + + System.out.println(daysOfWeek); + } +} diff --git a/src/test/java/javaPractice/collections/hashSet/CreateHashSetFromCollectionExample.java b/src/test/java/javaPractice/collections/hashSet/CreateHashSetFromCollectionExample.java new file mode 100644 index 0000000..6cd8ef3 --- /dev/null +++ b/src/test/java/javaPractice/collections/hashSet/CreateHashSetFromCollectionExample.java @@ -0,0 +1,32 @@ +package javaPractice.collections.hashSet; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class CreateHashSetFromCollectionExample { + public static void main(String[] args) { + List numbersDivisibleBy5 = new ArrayList<>(); + numbersDivisibleBy5.add(5); + numbersDivisibleBy5.add(10); + numbersDivisibleBy5.add(15); + numbersDivisibleBy5.add(20); + numbersDivisibleBy5.add(25); + + List numbersDivisibleBy3 = new ArrayList<>(); + numbersDivisibleBy3.add(3); + numbersDivisibleBy3.add(6); + numbersDivisibleBy3.add(9); + numbersDivisibleBy3.add(12); + numbersDivisibleBy3.add(15); + + // Creating a HashSet from another collection (ArrayList) + Set numbersDivisibleBy5Or3 = new HashSet<>(numbersDivisibleBy5); + + // Adding all the elements from an existing collection to a HashSet + numbersDivisibleBy5Or3.addAll(numbersDivisibleBy3); + + System.out.println(numbersDivisibleBy5Or3); + } +} diff --git a/src/test/java/javaPractice/collections/hashSet/HashSetRemoveExample.java b/src/test/java/javaPractice/collections/hashSet/HashSetRemoveExample.java new file mode 100644 index 0000000..ed6c545 --- /dev/null +++ b/src/test/java/javaPractice/collections/hashSet/HashSetRemoveExample.java @@ -0,0 +1,43 @@ +package javaPractice.collections.hashSet; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class HashSetRemoveExample { + public static void main(String[] args) { + Set numbers = new HashSet<>(); + numbers.add(2); + numbers.add(3); + numbers.add(4); + numbers.add(5); + numbers.add(6); + numbers.add(7); + numbers.add(8); + numbers.add(9); + numbers.add(10); + + System.out.println("numbers : " + numbers); + + // Remove an element from a HashSet (The remove() method returns false if the element does not exist in the HashSet) + boolean isRemoved = numbers.remove(10); + System.out.println("After remove(10) => " + numbers); + + // Remove all elements belonging to a given collection from a HashSet + List perfectSquares = new ArrayList<>(); + perfectSquares.add(4); + perfectSquares.add(9); + + numbers.removeAll(perfectSquares); + System.out.println("After removeAll(perfectSquares) => " + numbers); + + // Remove all elements matching a given predicate + numbers.removeIf(num -> num % 2 == 0); + System.out.println("After removeIf() => " + numbers); + + // Remove all elements from HashSet (clear it completely) + numbers.clear(); + System.out.println("After clear() => " + numbers); + } +} diff --git a/src/test/java/javaPractice/collections/hashSet/HashSetSimpleOperationsExample.java b/src/test/java/javaPractice/collections/hashSet/HashSetSimpleOperationsExample.java new file mode 100644 index 0000000..ee7353c --- /dev/null +++ b/src/test/java/javaPractice/collections/hashSet/HashSetSimpleOperationsExample.java @@ -0,0 +1,29 @@ +package javaPractice.collections.hashSet; + +import java.util.HashSet; +import java.util.Set; + +public class HashSetSimpleOperationsExample { + public static void main(String[] args) { + Set popularCities = new HashSet<>(); + + // Check if a HashSet is empty + System.out.println("Is popularCities set empty? : " + popularCities.isEmpty()); + + popularCities.add("London"); + popularCities.add("New York"); + popularCities.add("Paris"); + popularCities.add("Dubai"); + + // Find the size of a HashSet + System.out.println("Number of cities in the HashSet " + popularCities.size()); + + // Check if the HashSet contains an element + String cityName = "Paris"; + if (popularCities.contains(cityName)) { + System.out.println(cityName + " is in the popular cities set."); + } else { + System.out.println(cityName + " is not in the popular cities set."); + } + } +} diff --git a/src/test/java/javaPractice/collections/hashSet/HashSetUserDefinedObjectExample.java b/src/test/java/javaPractice/collections/hashSet/HashSetUserDefinedObjectExample.java new file mode 100644 index 0000000..04b14e7 --- /dev/null +++ b/src/test/java/javaPractice/collections/hashSet/HashSetUserDefinedObjectExample.java @@ -0,0 +1,69 @@ +package javaPractice.collections.hashSet; + +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +class Customer { + private long id; + private String name; + + public Customer(long id, String name) { + this.id = id; + this.name = name; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Customer customer = (Customer) o; + return id == customer.id; + } + + @Override + public int hashCode() { + return Objects.hash(id); + } + + @Override + public String toString() { + return "Customer{" + + "id=" + id + + ", name='" + name + '\'' + + '}'; + } +} + +public class HashSetUserDefinedObjectExample { + public static void main(String[] args) { + Set customers = new HashSet<>(); + customers.add(new Customer(101, "Rajeev")); + customers.add(new Customer(102, "Sachin")); + customers.add(new Customer(103, "Chris")); + + /* + HashSet will use the `equals()` & `hashCode()` implementations + of the Customer class to check for duplicates and ignore them + */ + customers.add(new Customer(101, "Rajeev")); + + System.out.println(customers); + } +} diff --git a/src/test/java/javaPractice/collections/hashSet/IterateOverHashSetExample.java b/src/test/java/javaPractice/collections/hashSet/IterateOverHashSetExample.java new file mode 100644 index 0000000..757a671 --- /dev/null +++ b/src/test/java/javaPractice/collections/hashSet/IterateOverHashSetExample.java @@ -0,0 +1,40 @@ +package javaPractice.collections.hashSet; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +public class IterateOverHashSetExample { + public static void main(String[] args) { + Set programmingLanguages = new HashSet<>(); + programmingLanguages.add("C"); + programmingLanguages.add("C++"); + programmingLanguages.add("Java"); + programmingLanguages.add("Python"); + programmingLanguages.add("PHP"); + programmingLanguages.add("Ruby"); + + System.out.println("=== Iterate over a HashSet using Java 8 forEach and lambda ==="); + programmingLanguages.forEach(programmingLanguage -> { + System.out.println(programmingLanguage); + }); + + System.out.println("=== Iterate over a HashSet using iterator() ==="); + Iterator programmingLanguageIterator = programmingLanguages.iterator(); + while (programmingLanguageIterator.hasNext()) { + String programmingLanguage = programmingLanguageIterator.next(); + System.out.println(programmingLanguage); + } + + System.out.println("=== Iterate over a HashSet using iterator() and Java 8 forEachRemaining() method ==="); + programmingLanguageIterator = programmingLanguages.iterator(); + programmingLanguageIterator.forEachRemaining(programmingLanguage -> { + System.out.println(programmingLanguage); + }); + + System.out.println("=== Iterate over a HashSet using simple for-each loop ==="); + for (String programmingLanguage : programmingLanguages) { + System.out.println(programmingLanguage); + } + } +} diff --git a/src/test/java/javaPractice/collections/linkedHashMap/AccessEntriesFromLinkedHashMapExample.java b/src/test/java/javaPractice/collections/linkedHashMap/AccessEntriesFromLinkedHashMapExample.java new file mode 100644 index 0000000..38d5f13 --- /dev/null +++ b/src/test/java/javaPractice/collections/linkedHashMap/AccessEntriesFromLinkedHashMapExample.java @@ -0,0 +1,38 @@ +package javaPractice.collections.linkedHashMap; + +import java.util.LinkedHashMap; + +public class AccessEntriesFromLinkedHashMapExample { + public static void main(String[] args) { + LinkedHashMap customerIdNameMapping = new LinkedHashMap<>(); + + customerIdNameMapping.put(1001, "Jack"); + customerIdNameMapping.put(1002, "David"); + customerIdNameMapping.put(1003, "Steve"); + customerIdNameMapping.put(1004, "Alice"); + customerIdNameMapping.put(1005, "Marie"); + + System.out.println("customerIdNameMapping : " + customerIdNameMapping); + + // Check if a key exists in the LinkedHashMap + Integer id = 1005; + if (customerIdNameMapping.containsKey(id)) { + System.out.println("Found the customer with id " + id + " : " + customerIdNameMapping.get(id)); + } else { + System.out.println("Customer with id " + id + " does not exist"); + } + + // Check if a value exists in the LinkedHashMap + String name = "David"; + if (customerIdNameMapping.containsValue(name)) { + System.out.println("A customer named " + name + " exist in the map"); + } else { + System.out.println("No customer found with name " + name + " in the map"); + } + + // Change the value associated with an existing key + id = 1004; + customerIdNameMapping.put(id, "Bob"); + System.out.println("Changed the name of customer with id " + id + ", New mapping : " + customerIdNameMapping); + } +} diff --git a/src/test/java/javaPractice/collections/linkedHashMap/CreateLinkedHashMapExample.java b/src/test/java/javaPractice/collections/linkedHashMap/CreateLinkedHashMapExample.java new file mode 100644 index 0000000..3c20ec1 --- /dev/null +++ b/src/test/java/javaPractice/collections/linkedHashMap/CreateLinkedHashMapExample.java @@ -0,0 +1,22 @@ +package javaPractice.collections.linkedHashMap; + +import java.util.LinkedHashMap; + +public class CreateLinkedHashMapExample { + public static void main(String[] args) { + // Creating a LinkedHashMap + LinkedHashMap wordNumberMapping = new LinkedHashMap<>(); + + // Adding new key-value pairs to the LinkedHashMap + wordNumberMapping.put("one", 1); + wordNumberMapping.put("two", 2); + wordNumberMapping.put("three", 3); + wordNumberMapping.put("four", 4); + + // Add a new key-value pair only if the key does not exist in the LinkedHashMap, or is mapped to `null` + wordNumberMapping.putIfAbsent("five", 5); + + + System.out.println(wordNumberMapping); + } +} diff --git a/src/test/java/javaPractice/collections/linkedHashMap/IterateOverLinkedHashMapExample.java b/src/test/java/javaPractice/collections/linkedHashMap/IterateOverLinkedHashMapExample.java new file mode 100644 index 0000000..91b999c --- /dev/null +++ b/src/test/java/javaPractice/collections/linkedHashMap/IterateOverLinkedHashMapExample.java @@ -0,0 +1,40 @@ +package javaPractice.collections.linkedHashMap; + +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; + +public class IterateOverLinkedHashMapExample { + public static void main(String[] args) { + LinkedHashMap userCityMapping = new LinkedHashMap<>(); + + userCityMapping.put("Rajeev", "Bengaluru"); + userCityMapping.put("Chris", "London"); + userCityMapping.put("David", "Paris"); + userCityMapping.put("Jesse", "California"); + + System.out.println("=== Iterating over a LinkedHashMap using Java 8 forEach and lambda ==="); + userCityMapping.forEach((user, city) -> { + System.out.println(user + " => " + city); + }); + + + System.out.println("\n=== Iterating over the LinkedHashMap's entrySet using Java 8 forEach and lambda ==="); + userCityMapping.entrySet().forEach(entry -> { + System.out.println(entry.getKey() + " => " + entry.getValue()); + }); + + System.out.println("\n=== Iterating over the entrySet of a LinkedHashMap using iterator() ==="); + Iterator> userCityMappingIterator = userCityMapping.entrySet().iterator(); + while (userCityMappingIterator.hasNext()) { + Map.Entry entry = userCityMappingIterator.next(); + System.out.println(entry.getKey() + " => " + entry.getValue()); + } + + System.out.println("\n=== Iterating over the entrySet of a LinkedHashMap using iterator() and forEachRemaining ==="); + userCityMappingIterator = userCityMapping.entrySet().iterator(); + userCityMappingIterator.forEachRemaining(entry -> { + System.out.println(entry.getKey() + " => " + entry.getValue()); + }); + } +} diff --git a/src/test/java/javaPractice/collections/linkedHashMap/RemoveEntriesFromLinkedHashMapExample.java b/src/test/java/javaPractice/collections/linkedHashMap/RemoveEntriesFromLinkedHashMapExample.java new file mode 100644 index 0000000..e574947 --- /dev/null +++ b/src/test/java/javaPractice/collections/linkedHashMap/RemoveEntriesFromLinkedHashMapExample.java @@ -0,0 +1,24 @@ +package javaPractice.collections.linkedHashMap; + +import java.util.LinkedHashMap; + +public class RemoveEntriesFromLinkedHashMapExample { + public static void main(String[] args) { + LinkedHashMap husbandWifeMapping = new LinkedHashMap<>(); + + husbandWifeMapping.put("Rajeev", "Jennifer"); + husbandWifeMapping.put("John", "Maria"); + husbandWifeMapping.put("Chris", "Lisa"); + husbandWifeMapping.put("Steve", "Susan"); + + System.out.println("husbandWifeMapping : " + husbandWifeMapping); + + // Remove a key from the LinkedHashMap + String wife = husbandWifeMapping.remove("John"); + System.out.println("Removed John and his wife " + wife + " from the mapping. New husbandWifeMapping : " + husbandWifeMapping); + + // Remove a key from the LinkedHashMap only if it is mapped to the given value + boolean isRemoved = husbandWifeMapping.remove("John", "Susan"); + System.out.println("Did John get removed from the mapping? : " + isRemoved); + } +} diff --git a/src/test/java/javaPractice/collections/linkedList/CreateLinkedListExample.java b/src/test/java/javaPractice/collections/linkedList/CreateLinkedListExample.java new file mode 100644 index 0000000..b4330b6 --- /dev/null +++ b/src/test/java/javaPractice/collections/linkedList/CreateLinkedListExample.java @@ -0,0 +1,40 @@ +package javaPractice.collections.linkedList; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +public class CreateLinkedListExample { + public static void main(String[] args) { + // Creating a LinkedList + LinkedList friends = new LinkedList<>(); + + // Adding new elements to the end of the LinkedList using add() method. + friends.add("Rajeev"); + friends.add("John"); + friends.add("David"); + friends.add("Chris"); + + System.out.println("Initial LinkedList : " + friends); + + // Adding an element at the specified position in the LinkedList + friends.add(3, "Lisa"); + System.out.println("After add(3, \"Lisa\") : " + friends); + + // Adding an element at the beginning of the LinkedList + friends.addFirst("Steve"); + System.out.println("After addFirst(\"Steve\") : " + friends); + + // Adding an element at the end of the LinkedList (This method is equivalent to the add() method) + friends.addLast("Jennifer"); + System.out.println("After addLast(\"Jennifer\") : " + friends); + + // Adding all the elements from an existing collection to the end of the LinkedList + List familyFriends = new ArrayList<>(); + familyFriends.add("Jesse"); + familyFriends.add("Walt"); + + friends.addAll(familyFriends); + System.out.println("After addAll(familyFriends) : " + friends); + } +} diff --git a/src/test/java/javaPractice/collections/linkedList/IterateOverLinkedListExample.java b/src/test/java/javaPractice/collections/linkedList/IterateOverLinkedListExample.java new file mode 100644 index 0000000..86d372d --- /dev/null +++ b/src/test/java/javaPractice/collections/linkedList/IterateOverLinkedListExample.java @@ -0,0 +1,57 @@ +package javaPractice.collections.linkedList; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.ListIterator; + +public class IterateOverLinkedListExample { + public static void main(String[] args) { + LinkedList humanSpecies = new LinkedList<>(); + + humanSpecies.add("Homo Sapiens"); + humanSpecies.add("Homo Neanderthalensis"); + humanSpecies.add("Homo Erectus"); + humanSpecies.add("Home Habilis"); + + System.out.println("=== Iterate over a LinkedList using Java 8 forEach and lambda ==="); + humanSpecies.forEach(name -> { + System.out.println(name); + }); + + + System.out.println("\n=== Iterate over a LinkedList using iterator() ==="); + Iterator humanSpeciesIterator = humanSpecies.iterator(); + while (humanSpeciesIterator.hasNext()) { + String speciesName = humanSpeciesIterator.next(); + System.out.println(speciesName); + } + + System.out.println("\n=== Iterate over a LinkedList using iterator() and Java 8 forEachRemaining() method ==="); + humanSpeciesIterator = humanSpecies.iterator(); + humanSpeciesIterator.forEachRemaining(speciesName -> { + System.out.println(speciesName); + }); + + System.out.println("\n=== Iterate over a LinkedList using descendingIterator() ==="); + Iterator descendingHumanSpeciesIterator = humanSpecies.descendingIterator(); + while (descendingHumanSpeciesIterator.hasNext()) { + String speciesName = descendingHumanSpeciesIterator.next(); + System.out.println(speciesName); + } + + + System.out.println("\n=== Iterate over a LinkedList using listIterator() ==="); + // ListIterator can be used to iterate over the LinkedList in both forward and backward directions + // In this example, we start from the end of the list and traverse backwards + ListIterator humanSpeciesListIterator = humanSpecies.listIterator(humanSpecies.size()); + while (humanSpeciesListIterator.hasPrevious()) { + String speciesName = humanSpeciesListIterator.previous(); + System.out.println(speciesName); + } + + System.out.println("\n=== Iterate over a LinkedList using simple for-each loop ==="); + for (String speciesName : humanSpecies) { + System.out.println(speciesName); + } + } +} diff --git a/src/test/java/javaPractice/collections/linkedList/RemoveElementsFromLinkedListExample.java b/src/test/java/javaPractice/collections/linkedList/RemoveElementsFromLinkedListExample.java new file mode 100644 index 0000000..49e6a37 --- /dev/null +++ b/src/test/java/javaPractice/collections/linkedList/RemoveElementsFromLinkedListExample.java @@ -0,0 +1,42 @@ +package javaPractice.collections.linkedList; + +import java.util.LinkedList; + +public class RemoveElementsFromLinkedListExample { + public static void main(String[] args) { + LinkedList programmingLanguages = new LinkedList<>(); + + programmingLanguages.add("Assembly"); + programmingLanguages.add("Fortran"); + programmingLanguages.add("Pascal"); + programmingLanguages.add("C"); + programmingLanguages.add("C++"); + programmingLanguages.add("Java"); + programmingLanguages.add("C#"); + programmingLanguages.add("Kotlin"); + + System.out.println("Initial LinkedList = " + programmingLanguages); + + // Remove the first element in the LinkedList + String element = programmingLanguages.removeFirst(); // Throws NoSuchElementException if the LinkedList is empty + System.out.println("Removed the first element " + element + " => " + programmingLanguages); + + // Remove the last element in the LinkedList + element = programmingLanguages.removeLast(); // Throws NoSuchElementException if the LinkedList is empty + System.out.println("Removed the last element " + element + " => " + programmingLanguages); + + // Remove the first occurrence of the specified element from the LinkedList + boolean isRemoved = programmingLanguages.remove("C#"); + if (isRemoved) { + System.out.println("Removed C# => " + programmingLanguages); + } + + // Remove all the elements that satisfy the given predicate + programmingLanguages.removeIf(programmingLanguage -> programmingLanguage.startsWith("C")); + System.out.println("Removed elements starting with C => " + programmingLanguages); + + // Clear the LinkedList by removing all elements + programmingLanguages.clear(); + System.out.println("Cleared the LinkedList => " + programmingLanguages); + } +} diff --git a/src/test/java/javaPractice/collections/linkedList/RetrieveLinkedListElementsExample.java b/src/test/java/javaPractice/collections/linkedList/RetrieveLinkedListElementsExample.java new file mode 100644 index 0000000..17134ce --- /dev/null +++ b/src/test/java/javaPractice/collections/linkedList/RetrieveLinkedListElementsExample.java @@ -0,0 +1,31 @@ +package javaPractice.collections.linkedList; + +import java.util.LinkedList; + +public class RetrieveLinkedListElementsExample { + public static void main(String[] args) { + // A LinkedList containing Stock Prices of a company for the last 6 days + LinkedList stockPrices = new LinkedList<>(); + + stockPrices.add(45.00); + stockPrices.add(51.00); + stockPrices.add(62.50); + stockPrices.add(42.75); + stockPrices.add(36.80); + stockPrices.add(68.40); + + // Getting the first element in the LinkedList using getFirst() + // The getFirst() method throws NoSuchElementException if the LinkedList is empty + Double firstElement = stockPrices.getFirst(); + System.out.println("Initial Stock Price : " + firstElement); + + // Getting the last element in the LinkedList using getLast() + // The getLast() method throws NoSuchElementException if the LinkedList is empty + Double lastElement = stockPrices.getLast(); + System.out.println("Current Stock Price : " + lastElement); + + // Getting the element at a given position in the LinkedList + Double stockPriceOn3rdDay = stockPrices.get(2); + System.out.println("Stock Price on 3rd Day : " + stockPriceOn3rdDay); + } +} diff --git a/src/test/java/javaPractice/collections/linkedList/SearchLinkedListExample.java b/src/test/java/javaPractice/collections/linkedList/SearchLinkedListExample.java new file mode 100644 index 0000000..c1ae8e0 --- /dev/null +++ b/src/test/java/javaPractice/collections/linkedList/SearchLinkedListExample.java @@ -0,0 +1,27 @@ +package javaPractice.collections.linkedList; + +import java.util.LinkedList; + +public class SearchLinkedListExample { + public static void main(String[] args) { + LinkedList employees = new LinkedList<>(); + + employees.add("John"); + employees.add("David"); + employees.add("Lara"); + employees.add("Chris"); + employees.add("Steve"); + employees.add("David"); + + // Check if the LinkedList contains an element + System.out.println("Does Employees LinkedList contain \"Lara\"? : " + employees.contains("Lara")); + + // Find the index of the first occurrence of an element in the LinkedList + System.out.println("indexOf \"Steve\" : " + employees.indexOf("Steve")); + System.out.println("indexOf \"Mark\" : " + employees.indexOf("Mark")); + + // Find the index of the last occurrence of an element in the LinkedList + System.out.println("lastIndexOf \"David\" : " + employees.lastIndexOf("David")); + System.out.println("lastIndexOf \"Bob\" : " + employees.lastIndexOf("Bob")); + } +} diff --git a/src/test/java/javaPractice/collections/priorityQueue/CreatePriorityQueueExample.java b/src/test/java/javaPractice/collections/priorityQueue/CreatePriorityQueueExample.java new file mode 100644 index 0000000..d57da1c --- /dev/null +++ b/src/test/java/javaPractice/collections/priorityQueue/CreatePriorityQueueExample.java @@ -0,0 +1,22 @@ +package javaPractice.collections.priorityQueue; + +import java.util.PriorityQueue; + +public class CreatePriorityQueueExample { + public static void main(String[] args) { + // Create a Priority Queue + PriorityQueue numbers = new PriorityQueue<>(); + + // Add items to a Priority Queue (ENQUEUE) + numbers.add(750); + numbers.add(500); + numbers.add(900); + numbers.add(100); + + // Remove items from the Priority Queue (DEQUEUE) + while (!numbers.isEmpty()) { + System.out.println(numbers.remove()); + } + + } +} diff --git a/src/test/java/javaPractice/collections/priorityQueue/CreatePriorityQueueStringExample.java b/src/test/java/javaPractice/collections/priorityQueue/CreatePriorityQueueStringExample.java new file mode 100644 index 0000000..1a04b16 --- /dev/null +++ b/src/test/java/javaPractice/collections/priorityQueue/CreatePriorityQueueStringExample.java @@ -0,0 +1,24 @@ +package javaPractice.collections.priorityQueue; + +import java.util.PriorityQueue; + +public class CreatePriorityQueueStringExample { + public static void main(String[] args) { + // Create a Priority Queue + PriorityQueue namePriorityQueue = new PriorityQueue<>(); + + // Add items to a Priority Queue (ENQUEUE) + namePriorityQueue.add("Lisa"); + namePriorityQueue.add("Robert"); + namePriorityQueue.add("John"); + namePriorityQueue.add("Chris"); + namePriorityQueue.add("Angelina"); + namePriorityQueue.add("Joe"); + + // Remove items from the Priority Queue (DEQUEUE) + while (!namePriorityQueue.isEmpty()) { + System.out.println(namePriorityQueue.remove()); + } + + } +} diff --git a/src/test/java/javaPractice/collections/priorityQueue/PriorityQueueCustomComparatorExample.java b/src/test/java/javaPractice/collections/priorityQueue/PriorityQueueCustomComparatorExample.java new file mode 100644 index 0000000..d348a4a --- /dev/null +++ b/src/test/java/javaPractice/collections/priorityQueue/PriorityQueueCustomComparatorExample.java @@ -0,0 +1,41 @@ +package javaPractice.collections.priorityQueue; + +import java.util.Comparator; +import java.util.PriorityQueue; + +public class PriorityQueueCustomComparatorExample { + public static void main(String[] args) { + Comparator stringLengthComparator = new Comparator() { + @Override + public int compare(String s1, String s2) { + return s1.length() - s2.length(); + } + }; + + /* + The above Comparator can also be created using lambda expression like this => + Comparator stringLengthComparator = (s1, s2) -> { + return s1.length() - s2.length(); + }; + + The above statement can be shortened even further like this => + Comparator stringLengthComparator = Comparator.comparingInt(String::length); + */ + + // Create a Priority Queue with a custom Comparator + PriorityQueue namePriorityQueue = new PriorityQueue<>(stringLengthComparator); + + // Add items to a Priority Queue (ENQUEUE) + namePriorityQueue.add("Lisa"); + namePriorityQueue.add("Robert"); + namePriorityQueue.add("John"); + namePriorityQueue.add("Chris"); + namePriorityQueue.add("Angelina"); + namePriorityQueue.add("Joe"); + + // Remove items from the Priority Queue (DEQUEUE) + while (!namePriorityQueue.isEmpty()) { + System.out.println(namePriorityQueue.remove()); + } + } +} diff --git a/src/test/java/javaPractice/collections/priorityQueue/PriorityQueueUserDefinedObjectExample.java b/src/test/java/javaPractice/collections/priorityQueue/PriorityQueueUserDefinedObjectExample.java new file mode 100644 index 0000000..b450f67 --- /dev/null +++ b/src/test/java/javaPractice/collections/priorityQueue/PriorityQueueUserDefinedObjectExample.java @@ -0,0 +1,95 @@ +package javaPractice.collections.priorityQueue; + +import java.util.Objects; +import java.util.PriorityQueue; + +class Employee implements Comparable { + private String name; + private double salary; + + public Employee(String name, double salary) { + this.name = name; + this.salary = salary; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getSalary() { + return salary; + } + + public void setSalary(double salary) { + this.salary = salary; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Employee employee = (Employee) o; + return Double.compare(employee.salary, salary) == 0 && + Objects.equals(name, employee.name); + } + + @Override + public int hashCode() { + return Objects.hash(name, salary); + } + + @Override + public String toString() { + return "Employee{" + + "name='" + name + '\'' + + ", salary=" + salary + + '}'; + } + + // Compare two employee objects by their salary + @Override + public int compareTo(Employee employee) { + if (this.getSalary() > employee.getSalary()) { + return 1; + } else if (this.getSalary() < employee.getSalary()) { + return -1; + } else { + return 0; + } + } +} + + +public class PriorityQueueUserDefinedObjectExample { + public static void main(String[] args) { + /* + The requirement for a PriorityQueue of user defined objects is that + + 1. Either the class should implement the Comparable interface and provide + the implementation for the compareTo() function. + 2. Or you should provide a custom Comparator while creating the PriorityQueue. + */ + + // Create a PriorityQueue + PriorityQueue employeePriorityQueue = new PriorityQueue<>(); + + // Add items to the Priority Queue + employeePriorityQueue.add(new Employee("Rajeev", 100000.00)); + employeePriorityQueue.add(new Employee("Chris", 145000.00)); + employeePriorityQueue.add(new Employee("Andrea", 115000.00)); + employeePriorityQueue.add(new Employee("Jack", 167000.00)); + + + /* + The compareTo() method implemented in the Employee class is used to determine + in what order the objects should be dequeued. + */ + while (!employeePriorityQueue.isEmpty()) { + System.out.println(employeePriorityQueue.remove()); + } + } +} diff --git a/src/test/java/javaPractice/collections/queue/IterateOverQueueExample.java b/src/test/java/javaPractice/collections/queue/IterateOverQueueExample.java new file mode 100644 index 0000000..1a4bc66 --- /dev/null +++ b/src/test/java/javaPractice/collections/queue/IterateOverQueueExample.java @@ -0,0 +1,39 @@ +package javaPractice.collections.queue; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Queue; + +public class IterateOverQueueExample { + public static void main(String[] args) { + Queue waitingQueue = new LinkedList<>(); + + waitingQueue.add("John"); + waitingQueue.add("Brad"); + waitingQueue.add("Angelina"); + waitingQueue.add("Julia"); + + System.out.println("=== Iterating over a Queue using Java 8 forEach() ==="); + waitingQueue.forEach(name -> { + System.out.println(name); + }); + + System.out.println("\n=== Iterating over a Queue using iterator() ==="); + Iterator waitingQueueIterator = waitingQueue.iterator(); + while (waitingQueueIterator.hasNext()) { + String name = waitingQueueIterator.next(); + System.out.println(name); + } + + System.out.println("\n=== Iterating over a Queue using iterator() and Java 8 forEachRemaining() ==="); + waitingQueueIterator = waitingQueue.iterator(); + waitingQueueIterator.forEachRemaining(name -> { + System.out.println(name); + }); + + System.out.println("\n=== Iterating over a Queue using simple for-each loop ==="); + for (String name : waitingQueue) { + System.out.println(name); + } + } +} diff --git a/src/test/java/javaPractice/collections/queue/QueueExample.java b/src/test/java/javaPractice/collections/queue/QueueExample.java new file mode 100644 index 0000000..b8fbff4 --- /dev/null +++ b/src/test/java/javaPractice/collections/queue/QueueExample.java @@ -0,0 +1,30 @@ +package javaPractice.collections.queue; + +import java.util.LinkedList; +import java.util.Queue; + +public class QueueExample { + public static void main(String[] args) { + // Create and initialize a Queue using a LinkedList + Queue waitingQueue = new LinkedList<>(); + + // Adding new elements to the Queue (The Enqueue operation) + waitingQueue.add("Rajeev"); + waitingQueue.add("Chris"); + waitingQueue.add("John"); + waitingQueue.add("Mark"); + waitingQueue.add("Steven"); + + System.out.println("WaitingQueue : " + waitingQueue); + + // Removing an element from the Queue using remove() (The Dequeue operation) + // The remove() method throws NoSuchElementException if the Queue is empty + String name = waitingQueue.remove(); + System.out.println("Removed from WaitingQueue : " + name + " | New WaitingQueue : " + waitingQueue); + + // Removing an element from the Queue using poll() + // The poll() method is similar to remove() except that it returns null if the Queue is empty. + name = waitingQueue.poll(); + System.out.println("Removed from WaitingQueue : " + name + " | New WaitingQueue : " + waitingQueue); + } +} diff --git a/src/test/java/javaPractice/collections/queue/QueueSizeSearchFrontExample.java b/src/test/java/javaPractice/collections/queue/QueueSizeSearchFrontExample.java new file mode 100644 index 0000000..e406f18 --- /dev/null +++ b/src/test/java/javaPractice/collections/queue/QueueSizeSearchFrontExample.java @@ -0,0 +1,42 @@ +package javaPractice.collections.queue; + +import java.util.LinkedList; +import java.util.Queue; + +public class QueueSizeSearchFrontExample { + public static void main(String[] args) { + Queue waitingQueue = new LinkedList<>(); + + waitingQueue.add("Jennifer"); + waitingQueue.add("Angelina"); + waitingQueue.add("Johnny"); + waitingQueue.add("Sachin"); + + System.out.println("WaitingQueue : " + waitingQueue); + + // Check is a Queue is empty + System.out.println("is waitingQueue empty? : " + waitingQueue.isEmpty()); + + // Find the size of the Queue + System.out.println("Size of waitingQueue : " + waitingQueue.size()); + + // Check if the Queue contains an element + String name = "Johnny"; + if (waitingQueue.contains(name)) { + System.out.println("WaitingQueue contains " + name); + } else { + System.out.println("Waiting Queue doesn't contain " + name); + } + + // Get the element at the front of the Queue without removing it using element() + // The element() method throws NoSuchElementException if the Queue is empty + String firstPersonInTheWaitingQueue = waitingQueue.element(); + System.out.println("First Person in the Waiting Queue (element()) : " + firstPersonInTheWaitingQueue); + + // Get the element at the front of the Queue without removing it using peek() + // The peek() method is similar to element() except that it returns null if the Queue is empty + firstPersonInTheWaitingQueue = waitingQueue.peek(); + System.out.println("First Person in the Waiting Queue : " + firstPersonInTheWaitingQueue); + + } +} diff --git a/src/test/java/javaPractice/collections/stack/IterateOverStackExample.java b/src/test/java/javaPractice/collections/stack/IterateOverStackExample.java new file mode 100644 index 0000000..b3e419c --- /dev/null +++ b/src/test/java/javaPractice/collections/stack/IterateOverStackExample.java @@ -0,0 +1,45 @@ +package javaPractice.collections.stack; + +import java.util.Iterator; +import java.util.ListIterator; +import java.util.Stack; + +public class IterateOverStackExample { + public static void main(String[] args) { + Stack stackOfPlates = new Stack<>(); + + stackOfPlates.add("Plate 1"); + stackOfPlates.add("Plate 2"); + stackOfPlates.add("Plate 3"); + stackOfPlates.add("Plate 4"); + + System.out.println("=== Iterate over a Stack using Java 8 forEach() method ==="); + stackOfPlates.forEach(plate -> { + System.out.println(plate); + }); + + System.out.println("\n=== Iterate over a Stack using iterator() ==="); + Iterator platesIterator = stackOfPlates.iterator(); + while (platesIterator.hasNext()) { + String plate = platesIterator.next(); + System.out.println(plate); + } + + System.out.println("\n=== Iterate over a Stack using iterator() and Java 8 forEachRemaining() method ==="); + platesIterator = stackOfPlates.iterator(); + while (platesIterator.hasNext()) { + String plate = platesIterator.next(); + System.out.println(plate); + } + + + System.out.println("\n=== Iterate over a Stack from TOP to BOTTOM using listIterator() ==="); + // ListIterator allows you to traverse in both forward and backward directions. + // We'll start from the top of the stack and traverse backwards. + ListIterator platesListIterator = stackOfPlates.listIterator(stackOfPlates.size()); + while (platesListIterator.hasPrevious()) { + String plate = platesListIterator.previous(); + System.out.println(plate); + } + } +} diff --git a/src/test/java/javaPractice/collections/stack/StackExample.java b/src/test/java/javaPractice/collections/stack/StackExample.java new file mode 100644 index 0000000..54886b4 --- /dev/null +++ b/src/test/java/javaPractice/collections/stack/StackExample.java @@ -0,0 +1,31 @@ +package javaPractice.collections.stack; + +import java.util.Stack; + +public class StackExample { + public static void main(String[] args) { + // Creating a Stack + Stack stackOfCards = new Stack<>(); + + // Pushing new items to the Stack + stackOfCards.push("Jack"); + stackOfCards.push("Queen"); + stackOfCards.push("King"); + stackOfCards.push("Ace"); + + System.out.println("Stack => " + stackOfCards); + System.out.println(); + + // Popping items from the Stack + String cardAtTop = stackOfCards.pop(); // Throws EmptyStackException if the stack is empty + System.out.println("Stack.pop() => " + cardAtTop); + System.out.println("Current Stack => " + stackOfCards); + System.out.println(); + + // Get the item at the top of the stack without removing it + cardAtTop = stackOfCards.peek(); + System.out.println("Stack.peek() => " + cardAtTop); + System.out.println("Current Stack => " + stackOfCards); + + } +} diff --git a/src/test/java/javaPractice/collections/stack/StackSizeSearchExample.java b/src/test/java/javaPractice/collections/stack/StackSizeSearchExample.java new file mode 100644 index 0000000..4266d68 --- /dev/null +++ b/src/test/java/javaPractice/collections/stack/StackSizeSearchExample.java @@ -0,0 +1,34 @@ +package javaPractice.collections.stack; + +import java.util.Stack; + +public class StackSizeSearchExample { + public static void main(String[] args) { + Stack stackOfCards = new Stack<>(); + + stackOfCards.push("Jack"); + stackOfCards.push("Queen"); + stackOfCards.push("King"); + stackOfCards.push("Ace"); + + System.out.println("Stack : " + stackOfCards); + + // Check if the Stack is empty + System.out.println("Is Stack empty? : " + stackOfCards.isEmpty()); + + // Find the size of Stack + System.out.println("Size of Stack : " + stackOfCards.size()); + + // Search for an element + // The search() method returns the 1-based position of the element from the top of the stack + // It returns -1 if the element was not found in the stack + int position = stackOfCards.search("Queen"); + + if (position != -1) { + System.out.println("Found the element \"Queen\" at position : " + position); + } else { + System.out.println("Element not found"); + } + + } +} diff --git a/src/test/java/javaPractice/collections/treeMap/AccessEntriesFromTreeMapExample.java b/src/test/java/javaPractice/collections/treeMap/AccessEntriesFromTreeMapExample.java new file mode 100644 index 0000000..173f192 --- /dev/null +++ b/src/test/java/javaPractice/collections/treeMap/AccessEntriesFromTreeMapExample.java @@ -0,0 +1,42 @@ +package javaPractice.collections.treeMap; + +import java.util.Map; +import java.util.TreeMap; + +public class AccessEntriesFromTreeMapExample { + public static void main(String[] args) { + TreeMap employees = new TreeMap<>(); + + employees.put(1003, "Rajeev"); + employees.put(1001, "James"); + employees.put(1002, "Sachin"); + employees.put(1004, "Chris"); + + System.out.println("Employees map : " + employees); + + // Finding the size of a TreeMap + System.out.println("Total number of employees : " + employees.size()); + + // Check if a given key exists in a TreeMap + Integer id = 1004; + if (employees.containsKey(id)) { + // Get the value associated with a given key in a TreeMap + String name = employees.get(id); + System.out.println("Employee with id " + id + " : " + name); + } else { + System.out.println("Employee does not exist with id : " + id); + } + + // Find the first and last entry + System.out.println("First entry in employees map : " + employees.firstEntry()); + System.out.println("Last entry in employees map : " + employees.lastEntry()); + + // Find the entry whose key is just less than the given key + Map.Entry employeeJustBelow = employees.lowerEntry(1002); + System.out.println("Employee just below id 1002 : " + employeeJustBelow); + + // Find the entry whose key is just higher than the given key + Map.Entry employeeJustAbove = employees.higherEntry(1002); + System.out.println("Employee just above id 1002 : " + employeeJustAbove); + } +} diff --git a/src/test/java/javaPractice/collections/treeMap/CreateTreeMapCaseInsensitiveOrderExample.java b/src/test/java/javaPractice/collections/treeMap/CreateTreeMapCaseInsensitiveOrderExample.java new file mode 100644 index 0000000..78fc92b --- /dev/null +++ b/src/test/java/javaPractice/collections/treeMap/CreateTreeMapCaseInsensitiveOrderExample.java @@ -0,0 +1,29 @@ +package javaPractice.collections.treeMap; + +import java.util.SortedMap; +import java.util.TreeMap; + +public class CreateTreeMapCaseInsensitiveOrderExample { + public static void main(String[] args) { + // TreeMap with keys sorted by ignoring case + SortedMap fileExtensions = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + + /* + The above statement is the short form of - + SortedMap fileExtensions = new TreeMap<>(new Comparator() { + @Override + public int compare(String s1, String s2) { + return s1.compareToIgnoreCase(s2); + } + }); + */ + + fileExtensions.put("PYTHON", ".py"); + fileExtensions.put("c++", ".cpp"); + fileExtensions.put("KOTLIN", ".kt"); + fileExtensions.put("Golang", ".go"); + + // The keys will be sorted ignoring the case (Try removing String.CASE_INSENSITIVE_ORDER and see the output) + System.out.println(fileExtensions); + } +} diff --git a/src/test/java/javaPractice/collections/treeMap/CreateTreeMapCustomComparatorExample.java b/src/test/java/javaPractice/collections/treeMap/CreateTreeMapCustomComparatorExample.java new file mode 100644 index 0000000..4623091 --- /dev/null +++ b/src/test/java/javaPractice/collections/treeMap/CreateTreeMapCustomComparatorExample.java @@ -0,0 +1,33 @@ +package javaPractice.collections.treeMap; + +import java.util.Comparator; +import java.util.SortedMap; +import java.util.TreeMap; + +public class CreateTreeMapCustomComparatorExample { + public static void main(String[] args) { + // Creating a TreeMap with a Custom comparator (Descending order) + SortedMap fileExtensions = new TreeMap<>(new Comparator() { + @Override + public int compare(String s1, String s2) { + return s2.compareTo(s1); + } + }); + + /* + The above TreeMap with custom Comparator can be simply written as - + SortedMap fileExtensions = new TreeMap<>(Comparator.reverseOrder()); + */ + + // Adding new key-value pairs to a TreeMap + fileExtensions.put("python", ".py"); + fileExtensions.put("c++", ".cpp"); + fileExtensions.put("kotlin", ".kt"); + fileExtensions.put("golang", ".go"); + fileExtensions.put("java", ".java"); + + // Printing the TreeMap (The keys will be sorted based on the supplied comparator) + System.out.println(fileExtensions); + + } +} diff --git a/src/test/java/javaPractice/collections/treeMap/CreateTreeMapExample.java b/src/test/java/javaPractice/collections/treeMap/CreateTreeMapExample.java new file mode 100644 index 0000000..28181e0 --- /dev/null +++ b/src/test/java/javaPractice/collections/treeMap/CreateTreeMapExample.java @@ -0,0 +1,22 @@ +package javaPractice.collections.treeMap; + +import java.util.SortedMap; +import java.util.TreeMap; + +public class CreateTreeMapExample { + public static void main(String[] args) { + // Creating a TreeMap + SortedMap fileExtensions = new TreeMap<>(); + + // Adding new key-value pairs to a TreeMap + fileExtensions.put("python", ".py"); + fileExtensions.put("c++", ".cpp"); + fileExtensions.put("kotlin", ".kt"); + fileExtensions.put("golang", ".go"); + fileExtensions.put("java", ".java"); + + // Printing the TreeMap (Output will be sorted based on keys) + System.out.println(fileExtensions); + } + +} diff --git a/src/test/java/javaPractice/collections/treeMap/RemoveEntriesFromTreeMapExample.java b/src/test/java/javaPractice/collections/treeMap/RemoveEntriesFromTreeMapExample.java new file mode 100644 index 0000000..5123fcd --- /dev/null +++ b/src/test/java/javaPractice/collections/treeMap/RemoveEntriesFromTreeMapExample.java @@ -0,0 +1,41 @@ +package javaPractice.collections.treeMap; + +import java.util.Map; +import java.util.TreeMap; + +public class RemoveEntriesFromTreeMapExample { + public static void main(String[] args) { + TreeMap countryISOCodeMapping = new TreeMap<>(); + + countryISOCodeMapping.put("India", "IN"); + countryISOCodeMapping.put("United States of America", "US"); + countryISOCodeMapping.put("China", "CN"); + countryISOCodeMapping.put("United Kingdom", "UK"); + countryISOCodeMapping.put("Russia", "RU"); + countryISOCodeMapping.put("Japan", "JP"); + + System.out.println("CountryISOCodeMapping : " + countryISOCodeMapping); + + // Remove the mapping for a given key + String countryName = "Japan"; + String isoCode = countryISOCodeMapping.remove(countryName); + if (isoCode != null) { + System.out.println("Removed (" + countryName + " => " + isoCode + ") from the TreeMap. New TreeMap " + countryISOCodeMapping); + } else { + System.out.println(countryName + " does not exist, or it is mapped to a null value"); + } + + // Remove the mapping for the given key only if it is mapped to the given value + countryName = "India"; + boolean isRemoved = countryISOCodeMapping.remove(countryName, "IA"); + System.out.println("Was the mapping removed for " + countryName + "? : " + isRemoved); + + // Remove the first entry from the TreeMap + Map.Entry firstEntry = countryISOCodeMapping.pollFirstEntry(); + System.out.println("Removed firstEntry : " + firstEntry + ", New TreeMap : " + countryISOCodeMapping); + + // Remove the last entry from the TreeMap + Map.Entry lastEntry = countryISOCodeMapping.pollLastEntry(); + System.out.println("Removed lastEntry : " + lastEntry + ", New TreeMap : " + countryISOCodeMapping); + } +} \ No newline at end of file diff --git a/src/test/java/javaPractice/collections/treeSet/AccessTreeSetElementsExample.java b/src/test/java/javaPractice/collections/treeSet/AccessTreeSetElementsExample.java new file mode 100644 index 0000000..3240ea2 --- /dev/null +++ b/src/test/java/javaPractice/collections/treeSet/AccessTreeSetElementsExample.java @@ -0,0 +1,36 @@ +package javaPractice.collections.treeSet; + +import java.util.TreeSet; + +public class AccessTreeSetElementsExample { + public static void main(String[] args) { + TreeSet students = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); + + students.add("Julia"); + students.add("Robert"); + students.add("Mark"); + students.add("Steven"); + + System.out.println("Students TreeSet : " + students); + + // Finding the size of a TreeSet + System.out.println("Number of elements in the TreeSet : " + students.size()); + + // Check if an element exists in the TreeSet + String name = "Julia"; + if (students.contains(name)) { + System.out.println("TreeSet contains the element : " + name); + } else { + System.out.println("TreeSet does not contain the element : " + name); + } + + // Navigating through the TreeSet + System.out.println("First element : " + students.first()); + System.out.println("Last element : " + students.last()); + + name = "Robert"; + System.out.println("Element just greater than " + name + " : " + students.higher(name)); + System.out.println("Element just lower than " + name + " : " + students.lower(name)); + + } +} diff --git a/src/test/java/javaPractice/collections/treeSet/CreateTreeSetExample.java b/src/test/java/javaPractice/collections/treeSet/CreateTreeSetExample.java new file mode 100644 index 0000000..42bd067 --- /dev/null +++ b/src/test/java/javaPractice/collections/treeSet/CreateTreeSetExample.java @@ -0,0 +1,27 @@ +package javaPractice.collections.treeSet; + +import java.util.SortedSet; +import java.util.TreeSet; + +public class CreateTreeSetExample { + public static void main(String[] args) { + // Creating a TreeSet + SortedSet fruits = new TreeSet<>(); + + // Adding new elements to a TreeSet + fruits.add("Banana"); + fruits.add("Apple"); + fruits.add("Pineapple"); + fruits.add("Orange"); + + System.out.println("Fruits Set : " + fruits); + + // Duplicate elements are ignored + fruits.add("Apple"); + System.out.println("After adding duplicate element \"Apple\" : " + fruits); + + // This will be allowed because it's in lowercase. + fruits.add("banana"); + System.out.println("After adding \"banana\" : " + fruits); + } +} diff --git a/src/test/java/javaPractice/collections/treeSet/RemoveTreeSetElementsExample.java b/src/test/java/javaPractice/collections/treeSet/RemoveTreeSetElementsExample.java new file mode 100644 index 0000000..ff629e8 --- /dev/null +++ b/src/test/java/javaPractice/collections/treeSet/RemoveTreeSetElementsExample.java @@ -0,0 +1,39 @@ +package javaPractice.collections.treeSet; + +import java.util.TreeSet; + +public class RemoveTreeSetElementsExample { + public static void main(String[] args) { + TreeSet numbers = new TreeSet<>(); + + numbers.add(10); + numbers.add(15); + numbers.add(20); + numbers.add(25); + numbers.add(30); + numbers.add(42); + numbers.add(49); + numbers.add(50); + + System.out.println("numbers TreeSet : " + numbers); + + // Remove an element from the TreeSet + boolean isRemoved = numbers.remove(49); + if (isRemoved) { + System.out.println("After Removing 49 : " + numbers); + } + + // Remove all elements divisible by 3 + numbers.removeIf(number -> number % 3 == 0); + System.out.println("After removeIf() : " + numbers); + + + // Retrieve and remove the first element from the TreeSet + Integer num = numbers.pollFirst(); + System.out.println("Removed first element " + num + " from the TreeSet : " + numbers); + + // Retrieve and remove the last element from the TreeSet + num = numbers.pollLast(); + System.out.println("Removed last element " + num + " from the TreeSet : " + numbers); + } +} diff --git a/src/test/java/javaPractice/collections/treeSet/TreeSetCaseInsensitiveExample.java b/src/test/java/javaPractice/collections/treeSet/TreeSetCaseInsensitiveExample.java new file mode 100644 index 0000000..8696003 --- /dev/null +++ b/src/test/java/javaPractice/collections/treeSet/TreeSetCaseInsensitiveExample.java @@ -0,0 +1,33 @@ +package javaPractice.collections.treeSet; + +import java.util.SortedSet; +import java.util.TreeSet; + +public class TreeSetCaseInsensitiveExample { + public static void main(String[] args) { + // Creating a TreeSet with a custom Comparator (Case Insensitive Order) + SortedSet fruits = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); + + /* + The above TreeSet with the custom Comparator is the concise form of the following: + SortedSet fruits = new TreeSet<>(new Comparator() { + @Override + public int compare(String s1, String s2) { + return s1.compareToIgnoreCase(s2); + } + }); + */ + + // Adding new elements to a TreeSet + fruits.add("Banana"); + fruits.add("Apple"); + fruits.add("Pineapple"); + fruits.add("Orange"); + + System.out.println("Fruits Set : " + fruits); + + // Now, lowercase elements will also be considered as duplicates + fruits.add("banana"); + System.out.println("After adding \"banana\" : " + fruits); + } +} diff --git a/src/test/java/javaPractice/collections/treeSet/TreeSetDescendingOrderExample.java b/src/test/java/javaPractice/collections/treeSet/TreeSetDescendingOrderExample.java new file mode 100644 index 0000000..e486d4b --- /dev/null +++ b/src/test/java/javaPractice/collections/treeSet/TreeSetDescendingOrderExample.java @@ -0,0 +1,30 @@ +package javaPractice.collections.treeSet; + +import java.util.Comparator; +import java.util.SortedSet; +import java.util.TreeSet; + +public class TreeSetDescendingOrderExample { + public static void main(String[] args) { + // Creating a TreeSet with a custom Comparator (Descending Order) + SortedSet fruits = new TreeSet<>(Comparator.reverseOrder()); + + /* + The above TreeSet with the custom Comparator is the concise form of the following: + SortedSet fruits = new TreeSet<>(new Comparator() { + @Override + public int compare(String s1, String s2) { + return s2.compareTo(s1); + } + }); + */ + + // Adding new elements to a TreeSet + fruits.add("Banana"); + fruits.add("Apple"); + fruits.add("Pineapple"); + fruits.add("Orange"); + + System.out.println("Fruits Set : " + fruits); + } +} diff --git a/src/test/java/javaPractice/collections/treeSet/TreeSetUserDefinedObjectExample.java b/src/test/java/javaPractice/collections/treeSet/TreeSetUserDefinedObjectExample.java new file mode 100644 index 0000000..e7f8e5b --- /dev/null +++ b/src/test/java/javaPractice/collections/treeSet/TreeSetUserDefinedObjectExample.java @@ -0,0 +1,96 @@ +package javaPractice.collections.treeSet; + +import java.util.Comparator; +import java.util.Objects; +import java.util.SortedSet; +import java.util.TreeSet; + +class Employee implements Comparable { + private int id; + private String name; + + public Employee(int id, String name) { + this.id = id; + this.name = name; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + // Two Employees are equal if their IDs are equal + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Employee employee = (Employee) o; + return id == employee.id; + } + + @Override + public int hashCode() { + return Objects.hash(id); + } + + // Compare employees based on their IDs + @Override + public int compareTo(Employee employee) { + return this.getId() - employee.getId(); + } + + @Override + public String toString() { + return "Employee{" + + "id=" + id + + ", name='" + name + '\'' + + '}'; + } +} + + +public class TreeSetUserDefinedObjectExample { + public static void main(String[] args) { + // Creating a TreeSet of User Defined Objects. + + /* + The requirement for a TreeSet of user defined objects is that + + 1. Either the class should implement the Comparable interface and provide + the implementation for the compareTo() function. + 2. Or you should provide a custom Comparator while creating the TreeSet. + */ + + SortedSet employees = new TreeSet<>(); + + // TreeSet uses the compareTo() method of the Employee class to compare two employees and sort them + employees.add(new Employee(1010, "Rajeev")); + employees.add(new Employee(1005, "Sachin")); + employees.add(new Employee(1008, "Chris")); + + System.out.println("Employees (sorted based on Employee class's compareTo() function)"); + System.out.println(employees); + + // Providing a Custom Comparator (This comparator compares the employees based on their Name) + employees = new TreeSet<>(Comparator.comparing(Employee::getName)); + + employees.add(new Employee(1010, "Rajeev")); + employees.add(new Employee(1005, "Sachin")); + employees.add(new Employee(1008, "Chris")); + + System.out.println("\nEmployees (sorted based on the supplied Comparator)"); + System.out.println(employees); + + } +} diff --git a/src/test/java/java/controlStructure/branch/B_if_else_Statements.java b/src/test/java/javaPractice/controlStructure/branch/B_if_else_Statements.java similarity index 95% rename from src/test/java/java/controlStructure/branch/B_if_else_Statements.java rename to src/test/java/javaPractice/controlStructure/branch/B_if_else_Statements.java index ee21456..8fcdfd3 100644 --- a/src/test/java/java/controlStructure/branch/B_if_else_Statements.java +++ b/src/test/java/javaPractice/controlStructure/branch/B_if_else_Statements.java @@ -1,4 +1,4 @@ -package java.controlStructure.branch; +package javaPractice.controlStructure.branch; import java.util.Scanner; diff --git a/src/test/java/java/controlStructure/branch/C_Nested_if_statement.java b/src/test/java/javaPractice/controlStructure/branch/C_Nested_if_statement.java similarity index 96% rename from src/test/java/java/controlStructure/branch/C_Nested_if_statement.java rename to src/test/java/javaPractice/controlStructure/branch/C_Nested_if_statement.java index 9704104..2747cd6 100644 --- a/src/test/java/java/controlStructure/branch/C_Nested_if_statement.java +++ b/src/test/java/javaPractice/controlStructure/branch/C_Nested_if_statement.java @@ -1,4 +1,4 @@ -package java.controlStructure.branch; +package javaPractice.controlStructure.branch; import java.util.Scanner; diff --git a/src/test/java/java/controlStructure/branch/D_If_else_ifStatements.java b/src/test/java/javaPractice/controlStructure/branch/D_If_else_ifStatements.java similarity index 98% rename from src/test/java/java/controlStructure/branch/D_If_else_ifStatements.java rename to src/test/java/javaPractice/controlStructure/branch/D_If_else_ifStatements.java index 5178b83..909390f 100644 --- a/src/test/java/java/controlStructure/branch/D_If_else_ifStatements.java +++ b/src/test/java/javaPractice/controlStructure/branch/D_If_else_ifStatements.java @@ -1,4 +1,4 @@ -package java.controlStructure.branch; +package javaPractice.controlStructure.branch; import java.util.Scanner; diff --git a/src/test/java/java/controlStructure/branch/E_SwitchStatements.java b/src/test/java/javaPractice/controlStructure/branch/E_SwitchStatements.java similarity index 97% rename from src/test/java/java/controlStructure/branch/E_SwitchStatements.java rename to src/test/java/javaPractice/controlStructure/branch/E_SwitchStatements.java index fee1396..3800c90 100644 --- a/src/test/java/java/controlStructure/branch/E_SwitchStatements.java +++ b/src/test/java/javaPractice/controlStructure/branch/E_SwitchStatements.java @@ -1,4 +1,4 @@ -package java.controlStructure.branch; +package javaPractice.controlStructure.branch; import java.util.Scanner; diff --git a/src/test/java/java/controlStructure/branch/if_Statements.java b/src/test/java/javaPractice/controlStructure/branch/if_Statements.java similarity index 93% rename from src/test/java/java/controlStructure/branch/if_Statements.java rename to src/test/java/javaPractice/controlStructure/branch/if_Statements.java index 400ed01..6552b92 100644 --- a/src/test/java/java/controlStructure/branch/if_Statements.java +++ b/src/test/java/javaPractice/controlStructure/branch/if_Statements.java @@ -1,4 +1,4 @@ -package java.controlStructure.branch; +package javaPractice.controlStructure.branch; import java.util.Scanner; diff --git a/src/test/java/java/controlStructure/loop/A_WhileLoop.java b/src/test/java/javaPractice/controlStructure/loop/A_WhileLoop.java similarity index 96% rename from src/test/java/java/controlStructure/loop/A_WhileLoop.java rename to src/test/java/javaPractice/controlStructure/loop/A_WhileLoop.java index c764752..4439c6a 100644 --- a/src/test/java/java/controlStructure/loop/A_WhileLoop.java +++ b/src/test/java/javaPractice/controlStructure/loop/A_WhileLoop.java @@ -1,4 +1,4 @@ -package java.controlStructure.loop; +package javaPractice.controlStructure.loop; import java.util.Scanner; diff --git a/src/test/java/java/controlStructure/loop/B_DoWhileLoop.java b/src/test/java/javaPractice/controlStructure/loop/B_DoWhileLoop.java similarity index 95% rename from src/test/java/java/controlStructure/loop/B_DoWhileLoop.java rename to src/test/java/javaPractice/controlStructure/loop/B_DoWhileLoop.java index 65a8d16..aa277a0 100644 --- a/src/test/java/java/controlStructure/loop/B_DoWhileLoop.java +++ b/src/test/java/javaPractice/controlStructure/loop/B_DoWhileLoop.java @@ -1,4 +1,4 @@ -package java.controlStructure.loop; +package javaPractice.controlStructure.loop; import java.util.Scanner; diff --git a/src/test/java/java/controlStructure/loop/C1_ForLoop.java b/src/test/java/javaPractice/controlStructure/loop/C1_ForLoop.java similarity index 96% rename from src/test/java/java/controlStructure/loop/C1_ForLoop.java rename to src/test/java/javaPractice/controlStructure/loop/C1_ForLoop.java index 5aa4ddb..074a22c 100644 --- a/src/test/java/java/controlStructure/loop/C1_ForLoop.java +++ b/src/test/java/javaPractice/controlStructure/loop/C1_ForLoop.java @@ -1,4 +1,4 @@ -package java.controlStructure.loop; +package javaPractice.controlStructure.loop; import java.util.Scanner; diff --git a/src/test/java/java/controlStructure/loop/C2_ForLoop.java b/src/test/java/javaPractice/controlStructure/loop/C2_ForLoop.java similarity index 96% rename from src/test/java/java/controlStructure/loop/C2_ForLoop.java rename to src/test/java/javaPractice/controlStructure/loop/C2_ForLoop.java index c5ae700..f9e2188 100644 --- a/src/test/java/java/controlStructure/loop/C2_ForLoop.java +++ b/src/test/java/javaPractice/controlStructure/loop/C2_ForLoop.java @@ -1,4 +1,4 @@ -package java.controlStructure.loop; +package javaPractice.controlStructure.loop; import java.util.Scanner; diff --git a/src/test/java/java/controlStructure/loop/D_NestedLoop.java b/src/test/java/javaPractice/controlStructure/loop/D_NestedLoop.java similarity index 98% rename from src/test/java/java/controlStructure/loop/D_NestedLoop.java rename to src/test/java/javaPractice/controlStructure/loop/D_NestedLoop.java index 7e2c94a..96ec678 100644 --- a/src/test/java/java/controlStructure/loop/D_NestedLoop.java +++ b/src/test/java/javaPractice/controlStructure/loop/D_NestedLoop.java @@ -1,4 +1,4 @@ -package java.controlStructure.loop; +package javaPractice.controlStructure.loop; import java.util.Random; import java.util.Scanner; diff --git a/src/test/java/java/controlStructure/loop/L1_WhileLoop.java b/src/test/java/javaPractice/controlStructure/loop/L1_WhileLoop.java similarity index 80% rename from src/test/java/java/controlStructure/loop/L1_WhileLoop.java rename to src/test/java/javaPractice/controlStructure/loop/L1_WhileLoop.java index bd5cb4c..d11ecae 100644 --- a/src/test/java/java/controlStructure/loop/L1_WhileLoop.java +++ b/src/test/java/javaPractice/controlStructure/loop/L1_WhileLoop.java @@ -1,4 +1,4 @@ -package java.controlStructure.loop; +package javaPractice.controlStructure.loop; public class L1_WhileLoop { diff --git a/src/test/java/java/coursesJava/ClassStaticVar.java b/src/test/java/javaPractice/general/ClassStaticVar.java similarity index 91% rename from src/test/java/java/coursesJava/ClassStaticVar.java rename to src/test/java/javaPractice/general/ClassStaticVar.java index 39a534a..5ba0407 100644 --- a/src/test/java/java/coursesJava/ClassStaticVar.java +++ b/src/test/java/javaPractice/general/ClassStaticVar.java @@ -1,4 +1,4 @@ -package java.coursesJava; +package javaPractice.general; public class ClassStaticVar { diff --git a/src/test/java/java/coursesJava/DataTypes.java b/src/test/java/javaPractice/general/DataTypes.java similarity index 89% rename from src/test/java/java/coursesJava/DataTypes.java rename to src/test/java/javaPractice/general/DataTypes.java index bc77d3b..2cc9649 100644 --- a/src/test/java/java/coursesJava/DataTypes.java +++ b/src/test/java/javaPractice/general/DataTypes.java @@ -1,12 +1,4 @@ -package java.coursesJava; - -//hi this is my first java code -/*hi this is -my first java code -im so happy -*/ - - +package javaPractice.general; public class DataTypes { public static void main(String[] args) { diff --git a/src/test/java/java/coursesJava/DemoLinkedList.java b/src/test/java/javaPractice/general/DemoLinkedList.java similarity index 98% rename from src/test/java/java/coursesJava/DemoLinkedList.java rename to src/test/java/javaPractice/general/DemoLinkedList.java index ec3a7a0..09fb0e8 100644 --- a/src/test/java/java/coursesJava/DemoLinkedList.java +++ b/src/test/java/javaPractice/general/DemoLinkedList.java @@ -1,4 +1,4 @@ -package java.coursesJava; +package javaPractice.general; import java.util.LinkedList; diff --git a/src/test/java/java/coursesJava/Encaptest.java b/src/test/java/javaPractice/general/Encaptest.java similarity index 94% rename from src/test/java/java/coursesJava/Encaptest.java rename to src/test/java/javaPractice/general/Encaptest.java index 084f43b..c011870 100644 --- a/src/test/java/java/coursesJava/Encaptest.java +++ b/src/test/java/javaPractice/general/Encaptest.java @@ -1,4 +1,4 @@ -package java.coursesJava; +package javaPractice.general; // Encapsulation public class Encaptest { diff --git a/src/test/java/java/coursesJava/EnumeratedTypes.java b/src/test/java/javaPractice/general/EnumeratedTypes.java similarity index 90% rename from src/test/java/java/coursesJava/EnumeratedTypes.java rename to src/test/java/javaPractice/general/EnumeratedTypes.java index cc2299e..dfeeceb 100644 --- a/src/test/java/java/coursesJava/EnumeratedTypes.java +++ b/src/test/java/javaPractice/general/EnumeratedTypes.java @@ -1,4 +1,4 @@ -package java.coursesJava; +package javaPractice.general; enum Gender {Male, Female}; diff --git a/src/test/java/java/coursesJava/EnumeratedTypes2.java b/src/test/java/javaPractice/general/EnumeratedTypes2.java similarity index 54% rename from src/test/java/java/coursesJava/EnumeratedTypes2.java rename to src/test/java/javaPractice/general/EnumeratedTypes2.java index 4b9f0c1..54bc1b3 100644 --- a/src/test/java/java/coursesJava/EnumeratedTypes2.java +++ b/src/test/java/javaPractice/general/EnumeratedTypes2.java @@ -1,4 +1,4 @@ -package java.coursesJava; +package javaPractice.general; public class EnumeratedTypes2 { diff --git a/src/test/java/java/coursesJava/FileReader.java b/src/test/java/javaPractice/general/FileReader.java similarity index 96% rename from src/test/java/java/coursesJava/FileReader.java rename to src/test/java/javaPractice/general/FileReader.java index 010f0dc..36c2d0f 100644 --- a/src/test/java/java/coursesJava/FileReader.java +++ b/src/test/java/javaPractice/general/FileReader.java @@ -1,4 +1,4 @@ -package java.coursesJava; +package javaPractice.general; import java.io.BufferedReader; import java.io.File; diff --git a/src/test/java/java/coursesJava/FunctonInJava.java b/src/test/java/javaPractice/general/FunctonInJava.java similarity index 97% rename from src/test/java/java/coursesJava/FunctonInJava.java rename to src/test/java/javaPractice/general/FunctonInJava.java index 105d216..c831ca9 100644 --- a/src/test/java/java/coursesJava/FunctonInJava.java +++ b/src/test/java/javaPractice/general/FunctonInJava.java @@ -1,4 +1,4 @@ -package java.coursesJava; +package javaPractice.general; public class FunctonInJava { diff --git a/src/test/java/java/coursesJava/IncrementAndDecrement.java b/src/test/java/javaPractice/general/IncrementAndDecrement.java similarity index 96% rename from src/test/java/java/coursesJava/IncrementAndDecrement.java rename to src/test/java/javaPractice/general/IncrementAndDecrement.java index 9a466bf..5597a62 100644 --- a/src/test/java/java/coursesJava/IncrementAndDecrement.java +++ b/src/test/java/javaPractice/general/IncrementAndDecrement.java @@ -1,4 +1,4 @@ -package java.coursesJava; +package javaPractice.general; public class IncrementAndDecrement { diff --git a/src/test/java/java/coursesJava/InstanceVar.java b/src/test/java/javaPractice/general/InstanceVar.java similarity index 93% rename from src/test/java/java/coursesJava/InstanceVar.java rename to src/test/java/javaPractice/general/InstanceVar.java index 2761719..e93b321 100644 --- a/src/test/java/java/coursesJava/InstanceVar.java +++ b/src/test/java/javaPractice/general/InstanceVar.java @@ -1,4 +1,4 @@ -package java.coursesJava; +package javaPractice.general; public class InstanceVar { diff --git a/src/test/java/java/coursesJava/InterfaceTest.java b/src/test/java/javaPractice/general/InterfaceTest.java similarity index 74% rename from src/test/java/java/coursesJava/InterfaceTest.java rename to src/test/java/javaPractice/general/InterfaceTest.java index 7e46991..e0ded1a 100644 --- a/src/test/java/java/coursesJava/InterfaceTest.java +++ b/src/test/java/javaPractice/general/InterfaceTest.java @@ -1,4 +1,4 @@ -package java.coursesJava; +package javaPractice.general; public interface InterfaceTest { diff --git a/src/test/java/javaPractice/general/MyCalcuation.java b/src/test/java/javaPractice/general/MyCalcuation.java new file mode 100644 index 0000000..c9b621e --- /dev/null +++ b/src/test/java/javaPractice/general/MyCalcuation.java @@ -0,0 +1,28 @@ +package javaPractice.general; + +public class MyCalcuation { + public void muliplication(int fNum, int secNum) { + total = fNum * secNum; + System.out.println("The prodcut of the given numbers:" + total); + } + + int total; + + public void addition(int firstNum, int secondNum) { + total = firstNum + secondNum; + System.out.println("The sum of the given numbers: " + total); + } + + public void Subtraction(int firstNum, int secondNum) { + total = firstNum - secondNum; + System.out.println("The difference between the given numbers: " + total); + } + + public static void main(String[] args) { + MyCalcuation myCalc = new MyCalcuation(); + myCalc.addition(5, 6); + myCalc.Subtraction(10, 5); + myCalc.muliplication(5, 5); + } + +} diff --git a/src/test/java/java/coursesJava/RunEncap.java b/src/test/java/javaPractice/general/RunEncap.java similarity index 91% rename from src/test/java/java/coursesJava/RunEncap.java rename to src/test/java/javaPractice/general/RunEncap.java index a4848aa..6fea4ad 100644 --- a/src/test/java/java/coursesJava/RunEncap.java +++ b/src/test/java/javaPractice/general/RunEncap.java @@ -1,4 +1,4 @@ -package java.coursesJava; +package javaPractice.general; // Encapsulation public class RunEncap { diff --git a/src/test/java/java/coursesJava/TestInterface.java b/src/test/java/javaPractice/general/TestInterface.java similarity index 88% rename from src/test/java/java/coursesJava/TestInterface.java rename to src/test/java/javaPractice/general/TestInterface.java index dded8ff..df4166b 100644 --- a/src/test/java/java/coursesJava/TestInterface.java +++ b/src/test/java/javaPractice/general/TestInterface.java @@ -1,4 +1,4 @@ -package java.coursesJava; +package javaPractice.general; public class TestInterface implements InterfaceTest { diff --git a/src/test/java/java/coursesJava/TestLocalVar.java b/src/test/java/javaPractice/general/TestLocalVar.java similarity index 94% rename from src/test/java/java/coursesJava/TestLocalVar.java rename to src/test/java/javaPractice/general/TestLocalVar.java index d0ac62e..fb8fb60 100644 --- a/src/test/java/java/coursesJava/TestLocalVar.java +++ b/src/test/java/javaPractice/general/TestLocalVar.java @@ -1,4 +1,4 @@ -package java.coursesJava; +package javaPractice.general; public class TestLocalVar { diff --git a/src/test/java/java/coursesJava/TestLogicalOperators.java b/src/test/java/javaPractice/general/TestLogicalOperators.java similarity index 51% rename from src/test/java/java/coursesJava/TestLogicalOperators.java rename to src/test/java/javaPractice/general/TestLogicalOperators.java index 4f6f001..4050928 100644 --- a/src/test/java/java/coursesJava/TestLogicalOperators.java +++ b/src/test/java/javaPractice/general/TestLogicalOperators.java @@ -1,4 +1,4 @@ -package java.coursesJava; +package javaPractice.general; public class TestLogicalOperators { @@ -22,6 +22,27 @@ public static void main(String[] args) { // Logical operator Not ! System.out.println("What is the result of not 100 > 99 ? " + (!y)); + + int a = 25, b = 50; + + // == Equal To Operator + System.out.println("Is 25 equal to 50 ? " + (a == b)); + + // != Not Equal To Operator + System.out.println("Is 25 not equal to 50 ? " + (a != b)); + + // > Greater Than Operator + System.out.println("Is 25 greater than 50 ? " + (a > b)); + + // >= Greater Than or equal Operator + System.out.println("Is 25 greater than or equal 50 ? " + (a >= b)); + + // < Less Than Operator + System.out.println("Is 25 Less than 50 ? " + (a < b)); + + // <= Less Than or equal Operator + System.out.println("Is 25 less than or equal 50 ? " + (a <= b)); + } } diff --git a/src/test/java/java/oop/Month/A_Month.java b/src/test/java/javaPractice/oop/Month/A_Month.java similarity index 98% rename from src/test/java/java/oop/Month/A_Month.java rename to src/test/java/javaPractice/oop/Month/A_Month.java index 9ebb2fd..2eb2534 100644 --- a/src/test/java/java/oop/Month/A_Month.java +++ b/src/test/java/javaPractice/oop/Month/A_Month.java @@ -1,4 +1,4 @@ -package java.oop.Month; +package javaPractice.oop.Month; /* Overloading Methods * Within a class, you can have multiple methods that have the same name diff --git a/src/test/java/java/oop/Month/B_MonthConverter.java b/src/test/java/javaPractice/oop/Month/B_MonthConverter.java similarity index 87% rename from src/test/java/java/oop/Month/B_MonthConverter.java rename to src/test/java/javaPractice/oop/Month/B_MonthConverter.java index 2dd9423..ec78d65 100644 --- a/src/test/java/java/oop/Month/B_MonthConverter.java +++ b/src/test/java/javaPractice/oop/Month/B_MonthConverter.java @@ -1,4 +1,4 @@ -package java.oop.Month; +package javaPractice.oop.Month; public class B_MonthConverter { diff --git a/src/test/java/java/oop/abstraction/Rectangle.java b/src/test/java/javaPractice/oop/abstraction/Rectangle.java similarity index 93% rename from src/test/java/java/oop/abstraction/Rectangle.java rename to src/test/java/javaPractice/oop/abstraction/Rectangle.java index 5ab8399..277bfa4 100644 --- a/src/test/java/java/oop/abstraction/Rectangle.java +++ b/src/test/java/javaPractice/oop/abstraction/Rectangle.java @@ -1,4 +1,4 @@ -package java.oop.abstraction; +package javaPractice.oop.abstraction; public class Rectangle extends Shape { diff --git a/src/test/java/java/oop/abstraction/Shape.java b/src/test/java/javaPractice/oop/abstraction/Shape.java similarity index 79% rename from src/test/java/java/oop/abstraction/Shape.java rename to src/test/java/javaPractice/oop/abstraction/Shape.java index ebbd81e..f9a54cd 100644 --- a/src/test/java/java/oop/abstraction/Shape.java +++ b/src/test/java/javaPractice/oop/abstraction/Shape.java @@ -1,4 +1,4 @@ -package java.oop.abstraction; +package javaPractice.oop.abstraction; public abstract class Shape { abstract double calculateArea(); diff --git a/src/test/java/java/oop/abstraction/ShapeTester.java b/src/test/java/javaPractice/oop/abstraction/ShapeTester.java similarity index 84% rename from src/test/java/java/oop/abstraction/ShapeTester.java rename to src/test/java/javaPractice/oop/abstraction/ShapeTester.java index 0070954..866637a 100644 --- a/src/test/java/java/oop/abstraction/ShapeTester.java +++ b/src/test/java/javaPractice/oop/abstraction/ShapeTester.java @@ -1,4 +1,4 @@ -package java.oop.abstraction; +package javaPractice.oop.abstraction; public class ShapeTester { public static void main(String[] args) { diff --git a/src/test/java/java/oop/animals/Animal.java b/src/test/java/javaPractice/oop/animals/Animal.java similarity index 77% rename from src/test/java/java/oop/animals/Animal.java rename to src/test/java/javaPractice/oop/animals/Animal.java index caa55ee..514062a 100644 --- a/src/test/java/java/oop/animals/Animal.java +++ b/src/test/java/javaPractice/oop/animals/Animal.java @@ -1,4 +1,4 @@ -package java.oop.animals; +package javaPractice.oop.animals; public class Animal { diff --git a/src/test/java/java/oop/animals/Cat.java b/src/test/java/javaPractice/oop/animals/Cat.java similarity index 86% rename from src/test/java/java/oop/animals/Cat.java rename to src/test/java/javaPractice/oop/animals/Cat.java index 7f2de5c..ecee4b3 100644 --- a/src/test/java/java/oop/animals/Cat.java +++ b/src/test/java/javaPractice/oop/animals/Cat.java @@ -1,4 +1,4 @@ -package java.oop.animals; +package javaPractice.oop.animals; public class Cat extends Animal { diff --git a/src/test/java/java/oop/animals/Dog.java b/src/test/java/javaPractice/oop/animals/Dog.java similarity index 85% rename from src/test/java/java/oop/animals/Dog.java rename to src/test/java/javaPractice/oop/animals/Dog.java index fcb2160..cacce24 100644 --- a/src/test/java/java/oop/animals/Dog.java +++ b/src/test/java/javaPractice/oop/animals/Dog.java @@ -1,4 +1,4 @@ -package java.oop.animals; +package javaPractice.oop.animals; public class Dog extends Animal { @Override diff --git a/src/test/java/java/oop/animals/Zoo.java b/src/test/java/javaPractice/oop/animals/Zoo.java similarity index 96% rename from src/test/java/java/oop/animals/Zoo.java rename to src/test/java/javaPractice/oop/animals/Zoo.java index 09d2c32..1cf9500 100644 --- a/src/test/java/java/oop/animals/Zoo.java +++ b/src/test/java/javaPractice/oop/animals/Zoo.java @@ -1,4 +1,4 @@ -package java.oop.animals; +package javaPractice.oop.animals; public class Zoo { public static void main(String[] args) { diff --git a/src/test/java/java/oop/coins/Coin.java b/src/test/java/javaPractice/oop/coins/Coin.java similarity index 93% rename from src/test/java/java/oop/coins/Coin.java rename to src/test/java/javaPractice/oop/coins/Coin.java index 3f92d4c..eadf67b 100644 --- a/src/test/java/java/oop/coins/Coin.java +++ b/src/test/java/javaPractice/oop/coins/Coin.java @@ -1,4 +1,4 @@ -package java.oop.coins; +package javaPractice.oop.coins; import java.util.Random; diff --git a/src/test/java/java/oop/coins/CoinTossGame.java b/src/test/java/javaPractice/oop/coins/CoinTossGame.java similarity index 98% rename from src/test/java/java/oop/coins/CoinTossGame.java rename to src/test/java/javaPractice/oop/coins/CoinTossGame.java index 9579b8f..e0851f1 100644 --- a/src/test/java/java/oop/coins/CoinTossGame.java +++ b/src/test/java/javaPractice/oop/coins/CoinTossGame.java @@ -1,4 +1,4 @@ -package java.oop.coins; +package javaPractice.oop.coins; import java.util.Scanner; diff --git a/src/test/java/java/oop/coins/Player.java b/src/test/java/javaPractice/oop/coins/Player.java similarity index 92% rename from src/test/java/java/oop/coins/Player.java rename to src/test/java/javaPractice/oop/coins/Player.java index a1e7a1e..8356d26 100644 --- a/src/test/java/java/oop/coins/Player.java +++ b/src/test/java/javaPractice/oop/coins/Player.java @@ -1,4 +1,4 @@ -package java.oop.coins; +package javaPractice.oop.coins; public class Player { diff --git a/src/test/java/java/oop/constructor/Employee.java b/src/test/java/javaPractice/oop/constructor/Employee.java similarity index 97% rename from src/test/java/java/oop/constructor/Employee.java rename to src/test/java/javaPractice/oop/constructor/Employee.java index cbc870c..0ef9087 100644 --- a/src/test/java/java/oop/constructor/Employee.java +++ b/src/test/java/javaPractice/oop/constructor/Employee.java @@ -1,4 +1,4 @@ -package java.oop.constructor; +package javaPractice.oop.constructor; public class Employee { int emp_id; diff --git a/src/test/java/java/oop/constructor/MyFirstOOPProject.java b/src/test/java/javaPractice/oop/constructor/MyFirstOOPProject.java similarity index 91% rename from src/test/java/java/oop/constructor/MyFirstOOPProject.java rename to src/test/java/javaPractice/oop/constructor/MyFirstOOPProject.java index 17c2d45..5fc0f98 100644 --- a/src/test/java/java/oop/constructor/MyFirstOOPProject.java +++ b/src/test/java/javaPractice/oop/constructor/MyFirstOOPProject.java @@ -1,4 +1,4 @@ -package java.oop.constructor; +package javaPractice.oop.constructor; public class MyFirstOOPProject { public static void main(String[] args) { diff --git a/src/test/java/java/oop/inheritance_2/E1_Main.java b/src/test/java/javaPractice/oop/inheritance_2/E1_Main.java similarity index 94% rename from src/test/java/java/oop/inheritance_2/E1_Main.java rename to src/test/java/javaPractice/oop/inheritance_2/E1_Main.java index c43426f..0624fa8 100644 --- a/src/test/java/java/oop/inheritance_2/E1_Main.java +++ b/src/test/java/javaPractice/oop/inheritance_2/E1_Main.java @@ -1,4 +1,4 @@ -package java.oop.inheritance_2; +package javaPractice.oop.inheritance_2; public class E1_Main { public static void main(String[] args) { diff --git a/src/test/java/java/oop/inheritance_2/E2_PersonBaseClass.java b/src/test/java/javaPractice/oop/inheritance_2/E2_PersonBaseClass.java similarity index 96% rename from src/test/java/java/oop/inheritance_2/E2_PersonBaseClass.java rename to src/test/java/javaPractice/oop/inheritance_2/E2_PersonBaseClass.java index 2d66fe7..61ebdc0 100644 --- a/src/test/java/java/oop/inheritance_2/E2_PersonBaseClass.java +++ b/src/test/java/javaPractice/oop/inheritance_2/E2_PersonBaseClass.java @@ -1,4 +1,4 @@ -package java.oop.inheritance_2; +package javaPractice.oop.inheritance_2; public class E2_PersonBaseClass { String name; diff --git a/src/test/java/java/oop/inheritance_2/E3_Employee.java b/src/test/java/javaPractice/oop/inheritance_2/E3_Employee.java similarity index 94% rename from src/test/java/java/oop/inheritance_2/E3_Employee.java rename to src/test/java/javaPractice/oop/inheritance_2/E3_Employee.java index bedccb1..bd2f91c 100644 --- a/src/test/java/java/oop/inheritance_2/E3_Employee.java +++ b/src/test/java/javaPractice/oop/inheritance_2/E3_Employee.java @@ -1,4 +1,4 @@ -package java.oop.inheritance_2; +package javaPractice.oop.inheritance_2; public class E3_Employee extends E2_PersonBaseClass { diff --git a/src/test/java/java/oop/inheritance_2/E4_Student.java b/src/test/java/javaPractice/oop/inheritance_2/E4_Student.java similarity index 95% rename from src/test/java/java/oop/inheritance_2/E4_Student.java rename to src/test/java/javaPractice/oop/inheritance_2/E4_Student.java index 0c3c84c..1a10e51 100644 --- a/src/test/java/java/oop/inheritance_2/E4_Student.java +++ b/src/test/java/javaPractice/oop/inheritance_2/E4_Student.java @@ -1,4 +1,4 @@ -package java.oop.inheritance_2; +package javaPractice.oop.inheritance_2; public class E4_Student extends E2_PersonBaseClass { int study_level; diff --git a/src/test/java/java/oop/inheritance_2/E5_Salaried_Employee.java b/src/test/java/javaPractice/oop/inheritance_2/E5_Salaried_Employee.java similarity index 93% rename from src/test/java/java/oop/inheritance_2/E5_Salaried_Employee.java rename to src/test/java/javaPractice/oop/inheritance_2/E5_Salaried_Employee.java index 26c886a..d443ca4 100644 --- a/src/test/java/java/oop/inheritance_2/E5_Salaried_Employee.java +++ b/src/test/java/javaPractice/oop/inheritance_2/E5_Salaried_Employee.java @@ -1,4 +1,4 @@ -package java.oop.inheritance_2; +package javaPractice.oop.inheritance_2; public class E5_Salaried_Employee extends E3_Employee { double bonus; diff --git a/src/test/java/java/oop/inheriteance/A_Person.java b/src/test/java/javaPractice/oop/inheriteance/A_Person.java similarity index 92% rename from src/test/java/java/oop/inheriteance/A_Person.java rename to src/test/java/javaPractice/oop/inheriteance/A_Person.java index 2d612e7..51b5e06 100644 --- a/src/test/java/java/oop/inheriteance/A_Person.java +++ b/src/test/java/javaPractice/oop/inheriteance/A_Person.java @@ -1,4 +1,4 @@ -package java.oop.inheriteance; +package javaPractice.oop.inheriteance; public class A_Person { private String name; diff --git a/src/test/java/java/oop/inheriteance/B_Employee.java b/src/test/java/javaPractice/oop/inheriteance/B_Employee.java similarity index 92% rename from src/test/java/java/oop/inheriteance/B_Employee.java rename to src/test/java/javaPractice/oop/inheriteance/B_Employee.java index bd5ceb3..5c7fd60 100644 --- a/src/test/java/java/oop/inheriteance/B_Employee.java +++ b/src/test/java/javaPractice/oop/inheriteance/B_Employee.java @@ -1,4 +1,4 @@ -package java.oop.inheriteance; +package javaPractice.oop.inheriteance; public class B_Employee extends A_Person { private String employeeId; diff --git a/src/test/java/java/oop/inheriteance/C_Woman.java b/src/test/java/javaPractice/oop/inheriteance/C_Woman.java similarity index 72% rename from src/test/java/java/oop/inheriteance/C_Woman.java rename to src/test/java/javaPractice/oop/inheriteance/C_Woman.java index e329357..97da491 100644 --- a/src/test/java/java/oop/inheriteance/C_Woman.java +++ b/src/test/java/javaPractice/oop/inheriteance/C_Woman.java @@ -1,4 +1,4 @@ -package java.oop.inheriteance; +package javaPractice.oop.inheriteance; public class C_Woman extends A_Person { diff --git a/src/test/java/java/oop/inheriteance/D_Mother.java b/src/test/java/javaPractice/oop/inheriteance/D_Mother.java similarity index 53% rename from src/test/java/java/oop/inheriteance/D_Mother.java rename to src/test/java/javaPractice/oop/inheriteance/D_Mother.java index 06fed03..d74343b 100644 --- a/src/test/java/java/oop/inheriteance/D_Mother.java +++ b/src/test/java/javaPractice/oop/inheriteance/D_Mother.java @@ -1,4 +1,4 @@ -package java.oop.inheriteance; +package javaPractice.oop.inheriteance; public class D_Mother extends C_Woman { diff --git a/src/test/java/java/oop/inheriteance/E_inheritanceTester.java b/src/test/java/javaPractice/oop/inheriteance/E_inheritanceTester.java similarity index 85% rename from src/test/java/java/oop/inheriteance/E_inheritanceTester.java rename to src/test/java/javaPractice/oop/inheriteance/E_inheritanceTester.java index 740b75b..fdb7dc0 100644 --- a/src/test/java/java/oop/inheriteance/E_inheritanceTester.java +++ b/src/test/java/javaPractice/oop/inheriteance/E_inheritanceTester.java @@ -1,8 +1,8 @@ -package java.oop.inheriteance; +package javaPractice.oop.inheriteance; -import java.oop.overridingAndOverloading.A_Rectangle; -import java.oop.overridingAndOverloading.B_Square; +import javaPractice.oop.overridingAndOverloading.A_Rectangle; +import javaPractice.oop.overridingAndOverloading.B_Square; public class E_inheritanceTester { diff --git a/src/test/java/java/oop/interfaceClass/interface1/CD.java b/src/test/java/javaPractice/oop/interfaceClass/interface1/CD.java similarity index 92% rename from src/test/java/java/oop/interfaceClass/interface1/CD.java rename to src/test/java/javaPractice/oop/interfaceClass/interface1/CD.java index 9228829..1bc131e 100644 --- a/src/test/java/java/oop/interfaceClass/interface1/CD.java +++ b/src/test/java/javaPractice/oop/interfaceClass/interface1/CD.java @@ -1,4 +1,4 @@ -package java.oop.interfaceClass.interface1; +package javaPractice.oop.interfaceClass.interface1; public class CD implements RetailItem, Displayable { double price; diff --git a/src/test/java/java/oop/interfaceClass/interface1/Displayable.java b/src/test/java/javaPractice/oop/interfaceClass/interface1/Displayable.java similarity index 54% rename from src/test/java/java/oop/interfaceClass/interface1/Displayable.java rename to src/test/java/javaPractice/oop/interfaceClass/interface1/Displayable.java index 65fd157..8264eaa 100644 --- a/src/test/java/java/oop/interfaceClass/interface1/Displayable.java +++ b/src/test/java/javaPractice/oop/interfaceClass/interface1/Displayable.java @@ -1,4 +1,4 @@ -package java.oop.interfaceClass.interface1; +package javaPractice.oop.interfaceClass.interface1; public interface Displayable { public void display(); diff --git a/src/test/java/java/oop/interfaceClass/interface1/Main.java b/src/test/java/javaPractice/oop/interfaceClass/interface1/Main.java similarity index 78% rename from src/test/java/java/oop/interfaceClass/interface1/Main.java rename to src/test/java/javaPractice/oop/interfaceClass/interface1/Main.java index 61ef9c9..baf47e3 100644 --- a/src/test/java/java/oop/interfaceClass/interface1/Main.java +++ b/src/test/java/javaPractice/oop/interfaceClass/interface1/Main.java @@ -1,4 +1,4 @@ -package java.oop.interfaceClass.interface1; +package javaPractice.oop.interfaceClass.interface1; public class Main { public static void main(String[] args) { diff --git a/src/test/java/java/oop/interfaceClass/interface1/RetailItem.java b/src/test/java/javaPractice/oop/interfaceClass/interface1/RetailItem.java similarity index 65% rename from src/test/java/java/oop/interfaceClass/interface1/RetailItem.java rename to src/test/java/javaPractice/oop/interfaceClass/interface1/RetailItem.java index fdface2..2ae5b5e 100644 --- a/src/test/java/java/oop/interfaceClass/interface1/RetailItem.java +++ b/src/test/java/javaPractice/oop/interfaceClass/interface1/RetailItem.java @@ -1,4 +1,4 @@ -package java.oop.interfaceClass.interface1; +package javaPractice.oop.interfaceClass.interface1; public interface RetailItem { String storeName = "ABC"; diff --git a/src/test/java/java/oop/interfaceClass/interface2/Book.java b/src/test/java/javaPractice/oop/interfaceClass/interface2/Book.java similarity index 95% rename from src/test/java/java/oop/interfaceClass/interface2/Book.java rename to src/test/java/javaPractice/oop/interfaceClass/interface2/Book.java index 1bd6acd..b667bc5 100644 --- a/src/test/java/java/oop/interfaceClass/interface2/Book.java +++ b/src/test/java/javaPractice/oop/interfaceClass/interface2/Book.java @@ -1,4 +1,4 @@ -package java.oop.interfaceClass.interface2; +package javaPractice.oop.interfaceClass.interface2; public class Book implements Product { diff --git a/src/test/java/java/oop/interfaceClass/interface2/MainCustomer.java b/src/test/java/javaPractice/oop/interfaceClass/interface2/MainCustomer.java similarity index 73% rename from src/test/java/java/oop/interfaceClass/interface2/MainCustomer.java rename to src/test/java/javaPractice/oop/interfaceClass/interface2/MainCustomer.java index 88eabc6..1f027de 100644 --- a/src/test/java/java/oop/interfaceClass/interface2/MainCustomer.java +++ b/src/test/java/javaPractice/oop/interfaceClass/interface2/MainCustomer.java @@ -1,4 +1,4 @@ -package java.oop.interfaceClass.interface2; +package javaPractice.oop.interfaceClass.interface2; public class MainCustomer { public static void main(String[] args) { diff --git a/src/test/java/java/oop/interfaceClass/interface2/Product.java b/src/test/java/javaPractice/oop/interfaceClass/interface2/Product.java similarity index 83% rename from src/test/java/java/oop/interfaceClass/interface2/Product.java rename to src/test/java/javaPractice/oop/interfaceClass/interface2/Product.java index 9552e7c..48ed7ec 100644 --- a/src/test/java/java/oop/interfaceClass/interface2/Product.java +++ b/src/test/java/javaPractice/oop/interfaceClass/interface2/Product.java @@ -1,4 +1,4 @@ -package java.oop.interfaceClass.interface2; +package javaPractice.oop.interfaceClass.interface2; public interface Product { double getPrice(); diff --git a/src/test/java/java/oop/interfaceClass/interface3/Animal.java b/src/test/java/javaPractice/oop/interfaceClass/interface3/Animal.java similarity index 73% rename from src/test/java/java/oop/interfaceClass/interface3/Animal.java rename to src/test/java/javaPractice/oop/interfaceClass/interface3/Animal.java index caf8230..136e289 100644 --- a/src/test/java/java/oop/interfaceClass/interface3/Animal.java +++ b/src/test/java/javaPractice/oop/interfaceClass/interface3/Animal.java @@ -1,4 +1,4 @@ -package java.oop.interfaceClass.interface3; +package javaPractice.oop.interfaceClass.interface3; public abstract class Animal { diff --git a/src/test/java/java/oop/interfaceClass/interface3/Duck.java b/src/test/java/javaPractice/oop/interfaceClass/interface3/Duck.java similarity index 71% rename from src/test/java/java/oop/interfaceClass/interface3/Duck.java rename to src/test/java/javaPractice/oop/interfaceClass/interface3/Duck.java index c45ad12..4416046 100644 --- a/src/test/java/java/oop/interfaceClass/interface3/Duck.java +++ b/src/test/java/javaPractice/oop/interfaceClass/interface3/Duck.java @@ -1,4 +1,4 @@ -package java.oop.interfaceClass.interface3; +package javaPractice.oop.interfaceClass.interface3; public class Duck extends Animal { @Override diff --git a/src/test/java/java/oop/interfaceClass/interface3/Farm.java b/src/test/java/javaPractice/oop/interfaceClass/interface3/Farm.java similarity index 83% rename from src/test/java/java/oop/interfaceClass/interface3/Farm.java rename to src/test/java/javaPractice/oop/interfaceClass/interface3/Farm.java index 045b913..a55a9e5 100644 --- a/src/test/java/java/oop/interfaceClass/interface3/Farm.java +++ b/src/test/java/javaPractice/oop/interfaceClass/interface3/Farm.java @@ -1,4 +1,4 @@ -package java.oop.interfaceClass.interface3; +package javaPractice.oop.interfaceClass.interface3; public class Farm { public static void main(String[] args) { diff --git a/src/test/java/java/oop/interfaceClass/interface3/Pig.java b/src/test/java/javaPractice/oop/interfaceClass/interface3/Pig.java similarity index 71% rename from src/test/java/java/oop/interfaceClass/interface3/Pig.java rename to src/test/java/javaPractice/oop/interfaceClass/interface3/Pig.java index ba0bd15..8c6d48a 100644 --- a/src/test/java/java/oop/interfaceClass/interface3/Pig.java +++ b/src/test/java/javaPractice/oop/interfaceClass/interface3/Pig.java @@ -1,4 +1,4 @@ -package java.oop.interfaceClass.interface3; +package javaPractice.oop.interfaceClass.interface3; public class Pig extends Animal { @Override diff --git a/src/test/java/java/oop/overridingAndOverloading/A_Rectangle.java b/src/test/java/javaPractice/oop/overridingAndOverloading/A_Rectangle.java similarity index 93% rename from src/test/java/java/oop/overridingAndOverloading/A_Rectangle.java rename to src/test/java/javaPractice/oop/overridingAndOverloading/A_Rectangle.java index a0eccbc..702b383 100644 --- a/src/test/java/java/oop/overridingAndOverloading/A_Rectangle.java +++ b/src/test/java/javaPractice/oop/overridingAndOverloading/A_Rectangle.java @@ -1,4 +1,4 @@ -package java.oop.overridingAndOverloading; +package javaPractice.oop.overridingAndOverloading; public class A_Rectangle { protected double length; diff --git a/src/test/java/java/oop/overridingAndOverloading/B_Square.java b/src/test/java/javaPractice/oop/overridingAndOverloading/B_Square.java similarity index 81% rename from src/test/java/java/oop/overridingAndOverloading/B_Square.java rename to src/test/java/javaPractice/oop/overridingAndOverloading/B_Square.java index 95655eb..fc3b397 100644 --- a/src/test/java/java/oop/overridingAndOverloading/B_Square.java +++ b/src/test/java/javaPractice/oop/overridingAndOverloading/B_Square.java @@ -1,4 +1,4 @@ -package java.oop.overridingAndOverloading; +package javaPractice.oop.overridingAndOverloading; public class B_Square extends A_Rectangle { @Override diff --git a/src/test/java/java/oop/phone/A_PhoneBill.java b/src/test/java/javaPractice/oop/phone/A_PhoneBill.java similarity index 98% rename from src/test/java/java/oop/phone/A_PhoneBill.java rename to src/test/java/javaPractice/oop/phone/A_PhoneBill.java index dd40430..a7becc7 100644 --- a/src/test/java/java/oop/phone/A_PhoneBill.java +++ b/src/test/java/javaPractice/oop/phone/A_PhoneBill.java @@ -1,4 +1,4 @@ -package java.oop.phone; +package javaPractice.oop.phone; public class A_PhoneBill { private double baseCost; diff --git a/src/test/java/java/oop/phone/B_PhoneBillCalculator.java b/src/test/java/javaPractice/oop/phone/B_PhoneBillCalculator.java similarity index 86% rename from src/test/java/java/oop/phone/B_PhoneBillCalculator.java rename to src/test/java/javaPractice/oop/phone/B_PhoneBillCalculator.java index 3f34c37..f25d86e 100644 --- a/src/test/java/java/oop/phone/B_PhoneBillCalculator.java +++ b/src/test/java/javaPractice/oop/phone/B_PhoneBillCalculator.java @@ -1,4 +1,4 @@ -package java.oop.phone; +package javaPractice.oop.phone; public class B_PhoneBillCalculator { public static void main(String args[]) { diff --git a/src/test/java/java/revision/BasePlusCommissionEmployee.java b/src/test/java/javaPractice/revision/BasePlusCommissionEmployee.java similarity index 96% rename from src/test/java/java/revision/BasePlusCommissionEmployee.java rename to src/test/java/javaPractice/revision/BasePlusCommissionEmployee.java index b86cfa2..a50ad4c 100644 --- a/src/test/java/java/revision/BasePlusCommissionEmployee.java +++ b/src/test/java/javaPractice/revision/BasePlusCommissionEmployee.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package java.revision; +package javaPractice.revision; /** * @author admin diff --git a/src/test/java/java/revision/Commission_Employee.java b/src/test/java/javaPractice/revision/Commission_Employee.java similarity index 97% rename from src/test/java/java/revision/Commission_Employee.java rename to src/test/java/javaPractice/revision/Commission_Employee.java index 6dede33..8fa7b36 100644 --- a/src/test/java/java/revision/Commission_Employee.java +++ b/src/test/java/javaPractice/revision/Commission_Employee.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package java.revision; +package javaPractice.revision; /** * @author admin diff --git a/src/test/java/java/revision/Department.java b/src/test/java/javaPractice/revision/Department.java similarity index 98% rename from src/test/java/java/revision/Department.java rename to src/test/java/javaPractice/revision/Department.java index fb3ad13..59354cb 100644 --- a/src/test/java/java/revision/Department.java +++ b/src/test/java/javaPractice/revision/Department.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package java.revision; +package javaPractice.revision; import java.util.ArrayList; diff --git a/src/test/java/java/revision/Displayable.java b/src/test/java/javaPractice/revision/Displayable.java similarity index 92% rename from src/test/java/java/revision/Displayable.java rename to src/test/java/javaPractice/revision/Displayable.java index 5f98a91..fd771d6 100644 --- a/src/test/java/java/revision/Displayable.java +++ b/src/test/java/javaPractice/revision/Displayable.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package java.revision; +package javaPractice.revision; /** * @author admin diff --git a/src/test/java/java/revision/Employee.java b/src/test/java/javaPractice/revision/Employee.java similarity index 97% rename from src/test/java/java/revision/Employee.java rename to src/test/java/javaPractice/revision/Employee.java index 6409031..e4191d0 100644 --- a/src/test/java/java/revision/Employee.java +++ b/src/test/java/javaPractice/revision/Employee.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package java.revision; +package javaPractice.revision; /** * @author admin diff --git a/src/test/java/java/revision/HourlyEmployee.java b/src/test/java/javaPractice/revision/HourlyEmployee.java similarity index 97% rename from src/test/java/java/revision/HourlyEmployee.java rename to src/test/java/javaPractice/revision/HourlyEmployee.java index 8cc660d..f439ee4 100644 --- a/src/test/java/java/revision/HourlyEmployee.java +++ b/src/test/java/javaPractice/revision/HourlyEmployee.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package java.revision; +package javaPractice.revision; /** * @author admin diff --git a/src/test/java/java/revision/Revision.java b/src/test/java/javaPractice/revision/Revision.java similarity index 96% rename from src/test/java/java/revision/Revision.java rename to src/test/java/javaPractice/revision/Revision.java index 85fc312..559feeb 100644 --- a/src/test/java/java/revision/Revision.java +++ b/src/test/java/javaPractice/revision/Revision.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package java.revision; +package javaPractice.revision; /** * @author admin diff --git a/src/test/java/java/revision/SalariedEmployee.java b/src/test/java/javaPractice/revision/SalariedEmployee.java similarity index 98% rename from src/test/java/java/revision/SalariedEmployee.java rename to src/test/java/javaPractice/revision/SalariedEmployee.java index f1fd794..d76f6b9 100644 --- a/src/test/java/java/revision/SalariedEmployee.java +++ b/src/test/java/javaPractice/revision/SalariedEmployee.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package java.revision; +package javaPractice.revision; /** * @author admin diff --git a/src/test/java/java/string/PasswordValidator.java b/src/test/java/javaPractice/string/PasswordValidator.java similarity index 99% rename from src/test/java/java/string/PasswordValidator.java rename to src/test/java/javaPractice/string/PasswordValidator.java index 414108d..10bafb7 100644 --- a/src/test/java/java/string/PasswordValidator.java +++ b/src/test/java/javaPractice/string/PasswordValidator.java @@ -1,4 +1,4 @@ -package java.string; +package javaPractice.string; import java.util.Scanner; diff --git a/src/test/java/java/string/TextProcessor.java b/src/test/java/javaPractice/string/TextProcessor.java similarity index 98% rename from src/test/java/java/string/TextProcessor.java rename to src/test/java/javaPractice/string/TextProcessor.java index 843c142..5aa20bc 100644 --- a/src/test/java/java/string/TextProcessor.java +++ b/src/test/java/javaPractice/string/TextProcessor.java @@ -1,4 +1,4 @@ -package java.string; +package javaPractice.string; public class TextProcessor { diff --git a/src/test/java/visualTest/BaseTests.java b/src/test/java/visualTestPractice/BaseTests.java similarity index 96% rename from src/test/java/visualTest/BaseTests.java rename to src/test/java/visualTestPractice/BaseTests.java index 1d094d2..bfa88b5 100644 --- a/src/test/java/visualTest/BaseTests.java +++ b/src/test/java/visualTestPractice/BaseTests.java @@ -1,4 +1,4 @@ -package visualTest; +package visualTestPractice; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.AfterClass; diff --git a/src/test/java/visualTest/DynamicTests.java b/src/test/java/visualTestPractice/DynamicTests.java similarity index 92% rename from src/test/java/visualTest/DynamicTests.java rename to src/test/java/visualTestPractice/DynamicTests.java index ebd97b7..141b5ab 100644 --- a/src/test/java/visualTest/DynamicTests.java +++ b/src/test/java/visualTestPractice/DynamicTests.java @@ -1,4 +1,4 @@ -package visualTest; +package visualTestPractice; import com.applitools.eyes.MatchLevel; diff --git a/src/test/java/visualTest/EyesManager.java b/src/test/java/visualTestPractice/EyesManager.java similarity index 98% rename from src/test/java/visualTest/EyesManager.java rename to src/test/java/visualTestPractice/EyesManager.java index 84212d9..fbbebf4 100644 --- a/src/test/java/visualTest/EyesManager.java +++ b/src/test/java/visualTestPractice/EyesManager.java @@ -1,4 +1,4 @@ -package visualTest; +package visualTestPractice; import com.applitools.eyes.BatchInfo; import com.applitools.eyes.selenium.Eyes; diff --git a/src/test/java/visualTest/PDFTests.java b/src/test/java/visualTestPractice/PDFTests.java similarity index 98% rename from src/test/java/visualTest/PDFTests.java rename to src/test/java/visualTestPractice/PDFTests.java index 5348bcc..dc4630d 100644 --- a/src/test/java/visualTest/PDFTests.java +++ b/src/test/java/visualTestPractice/PDFTests.java @@ -1,4 +1,4 @@ -package visualTest; +package visualTestPractice; import practice.gui.pages.visualPage.InvoiceGeneratorPage; diff --git a/src/test/java/visualTest/ScrollTests.java b/src/test/java/visualTestPractice/ScrollTests.java similarity index 91% rename from src/test/java/visualTest/ScrollTests.java rename to src/test/java/visualTestPractice/ScrollTests.java index 947de0c..c3fd9da 100644 --- a/src/test/java/visualTest/ScrollTests.java +++ b/src/test/java/visualTestPractice/ScrollTests.java @@ -1,4 +1,4 @@ -package visualTest; +package visualTestPractice; import org.testng.annotations.Test; diff --git a/src/test/java/visualTest/SearchTests.java b/src/test/java/visualTestPractice/SearchTests.java similarity index 96% rename from src/test/java/visualTest/SearchTests.java rename to src/test/java/visualTestPractice/SearchTests.java index eeac9df..f118f28 100644 --- a/src/test/java/visualTest/SearchTests.java +++ b/src/test/java/visualTestPractice/SearchTests.java @@ -1,4 +1,4 @@ -package visualTest; +package visualTestPractice; import practice.gui.pages.visualPage.SearchPage; import junit.framework.Assert; diff --git a/src/test/java/visualTest/TheInternetTests.java b/src/test/java/visualTestPractice/TheInternetTests.java similarity index 97% rename from src/test/java/visualTest/TheInternetTests.java rename to src/test/java/visualTestPractice/TheInternetTests.java index 518f9c5..2d2f16e 100644 --- a/src/test/java/visualTest/TheInternetTests.java +++ b/src/test/java/visualTestPractice/TheInternetTests.java @@ -1,4 +1,4 @@ -package visualTest; +package visualTestPractice; import practice.gui.pages.visualPage.SortableDataTablesPage; diff --git a/src/test/java/web/BaseTests.java b/src/test/java/webPractice/BaseTests.java similarity index 96% rename from src/test/java/web/BaseTests.java rename to src/test/java/webPractice/BaseTests.java index e31382f..2914384 100644 --- a/src/test/java/web/BaseTests.java +++ b/src/test/java/webPractice/BaseTests.java @@ -1,4 +1,4 @@ -package web; +package webPractice; import com.engine.actions.BrowserActions; import com.engine.driver.DriverHelper; diff --git a/src/test/java/web/HandleHTMLCanvas.java b/src/test/java/webPractice/HandleHTMLCanvas.java similarity index 98% rename from src/test/java/web/HandleHTMLCanvas.java rename to src/test/java/webPractice/HandleHTMLCanvas.java index 3fe89ca..99a65b1 100644 --- a/src/test/java/web/HandleHTMLCanvas.java +++ b/src/test/java/webPractice/HandleHTMLCanvas.java @@ -1,4 +1,4 @@ -package web; +package webPractice; import io.qameta.allure.*; diff --git a/src/test/java/web/JQueryMenus.java b/src/test/java/webPractice/JQueryMenus.java similarity index 99% rename from src/test/java/web/JQueryMenus.java rename to src/test/java/webPractice/JQueryMenus.java index bfcd574..f23954f 100644 --- a/src/test/java/web/JQueryMenus.java +++ b/src/test/java/webPractice/JQueryMenus.java @@ -1,4 +1,4 @@ -package web; +package webPractice; import io.qameta.allure.*; diff --git a/src/test/java/web/browserInteractions/AlertsTests.java b/src/test/java/webPractice/browserInteractions/AlertsTests.java similarity index 97% rename from src/test/java/web/browserInteractions/AlertsTests.java rename to src/test/java/webPractice/browserInteractions/AlertsTests.java index 0de14bf..aa38cc3 100644 --- a/src/test/java/web/browserInteractions/AlertsTests.java +++ b/src/test/java/webPractice/browserInteractions/AlertsTests.java @@ -1,4 +1,4 @@ -package web.browserInteractions; +package webPractice.browserInteractions; import practice.gui.pages.alerts.AlertsPage; import practice.gui.pages.homePage.HomePage; diff --git a/src/test/java/web/browserInteractions/ConsoleLogs.java b/src/test/java/webPractice/browserInteractions/ConsoleLogs.java similarity index 96% rename from src/test/java/web/browserInteractions/ConsoleLogs.java rename to src/test/java/webPractice/browserInteractions/ConsoleLogs.java index 9be8bbc..8930f5c 100644 --- a/src/test/java/web/browserInteractions/ConsoleLogs.java +++ b/src/test/java/webPractice/browserInteractions/ConsoleLogs.java @@ -1,4 +1,4 @@ -package web.browserInteractions; +package webPractice.browserInteractions; import com.engine.actions.BrowserActions; import com.engine.actions.ElementActions; diff --git a/src/test/java/web/browserInteractions/CookiesTests.java b/src/test/java/webPractice/browserInteractions/CookiesTests.java similarity index 96% rename from src/test/java/web/browserInteractions/CookiesTests.java rename to src/test/java/webPractice/browserInteractions/CookiesTests.java index c6d27ca..851aaab 100644 --- a/src/test/java/web/browserInteractions/CookiesTests.java +++ b/src/test/java/webPractice/browserInteractions/CookiesTests.java @@ -1,4 +1,4 @@ -package web.browserInteractions; +package webPractice.browserInteractions; import io.qameta.allure.Epic; @@ -11,7 +11,7 @@ import org.testng.Assert; import org.testng.annotations.Test; import com.engine.actions.BrowserActions; -import web.BaseTests; +import webPractice.BaseTests; @Epic("Browser Interactions") @Feature("Windows") diff --git a/src/test/java/web/browserInteractions/DevToolsTest.java b/src/test/java/webPractice/browserInteractions/DevToolsTest.java similarity index 96% rename from src/test/java/web/browserInteractions/DevToolsTest.java rename to src/test/java/webPractice/browserInteractions/DevToolsTest.java index f051821..7dc8871 100644 --- a/src/test/java/web/browserInteractions/DevToolsTest.java +++ b/src/test/java/webPractice/browserInteractions/DevToolsTest.java @@ -1,4 +1,4 @@ -package web.browserInteractions; +package webPractice.browserInteractions; import com.engine.actions.BrowserActions; import com.engine.actions.ElementActions; diff --git a/src/test/java/web/browserInteractions/FramesTest.java b/src/test/java/webPractice/browserInteractions/FramesTest.java similarity index 96% rename from src/test/java/web/browserInteractions/FramesTest.java rename to src/test/java/webPractice/browserInteractions/FramesTest.java index d469ad1..235c158 100644 --- a/src/test/java/web/browserInteractions/FramesTest.java +++ b/src/test/java/webPractice/browserInteractions/FramesTest.java @@ -1,4 +1,4 @@ -package web.browserInteractions; +package webPractice.browserInteractions; import com.engine.actions.BrowserActions; import io.qameta.allure.*; @@ -8,7 +8,7 @@ import org.openqa.selenium.interactions.Actions; import org.testng.Assert; import org.testng.annotations.Test; -import web.BaseTests; +import webPractice.BaseTests; @Epic("Browser Interactions") @Feature("Frames") diff --git a/src/test/java/web/browserInteractions/GeoLocation.java b/src/test/java/webPractice/browserInteractions/GeoLocation.java similarity index 97% rename from src/test/java/web/browserInteractions/GeoLocation.java rename to src/test/java/webPractice/browserInteractions/GeoLocation.java index f08a544..c2f82b0 100644 --- a/src/test/java/web/browserInteractions/GeoLocation.java +++ b/src/test/java/webPractice/browserInteractions/GeoLocation.java @@ -1,4 +1,4 @@ -package web.browserInteractions; +package webPractice.browserInteractions; import org.openqa.selenium.chrome.ChromeDriver; diff --git a/src/test/java/web/browserInteractions/NavigationTests.java b/src/test/java/webPractice/browserInteractions/NavigationTests.java similarity index 88% rename from src/test/java/web/browserInteractions/NavigationTests.java rename to src/test/java/webPractice/browserInteractions/NavigationTests.java index f103a87..4990c70 100644 --- a/src/test/java/web/browserInteractions/NavigationTests.java +++ b/src/test/java/webPractice/browserInteractions/NavigationTests.java @@ -1,11 +1,11 @@ -package web.browserInteractions; +package webPractice.browserInteractions; import com.engine.evidence.ScreenShot; import io.qameta.allure.Epic; import io.qameta.allure.Feature; import org.testng.annotations.Test; import com.engine.actions.BrowserActions; -import web.BaseTests; +import webPractice.BaseTests; @Epic("Browser Interactions") @Feature("Navigation") diff --git a/src/test/java/web/browserInteractions/NetworkConditions.java b/src/test/java/webPractice/browserInteractions/NetworkConditions.java similarity index 96% rename from src/test/java/web/browserInteractions/NetworkConditions.java rename to src/test/java/webPractice/browserInteractions/NetworkConditions.java index 41481c9..700bfbe 100644 --- a/src/test/java/web/browserInteractions/NetworkConditions.java +++ b/src/test/java/webPractice/browserInteractions/NetworkConditions.java @@ -1,4 +1,4 @@ -package web.browserInteractions; +package webPractice.browserInteractions; import org.openqa.selenium.chrome.ChromeDriver; diff --git a/src/test/java/web/browserInteractions/ReferenceTests.java b/src/test/java/webPractice/browserInteractions/ReferenceTests.java similarity index 98% rename from src/test/java/web/browserInteractions/ReferenceTests.java rename to src/test/java/webPractice/browserInteractions/ReferenceTests.java index be9e750..901c927 100644 --- a/src/test/java/web/browserInteractions/ReferenceTests.java +++ b/src/test/java/webPractice/browserInteractions/ReferenceTests.java @@ -1,4 +1,4 @@ -package web.browserInteractions; +package webPractice.browserInteractions; import com.engine.driver.DriverHelper; import com.engine.evidence.Attachments; diff --git a/src/test/java/web/browserInteractions/ResponsiveTests.java b/src/test/java/webPractice/browserInteractions/ResponsiveTests.java similarity index 95% rename from src/test/java/web/browserInteractions/ResponsiveTests.java rename to src/test/java/webPractice/browserInteractions/ResponsiveTests.java index ccddb7d..f610bf5 100644 --- a/src/test/java/web/browserInteractions/ResponsiveTests.java +++ b/src/test/java/webPractice/browserInteractions/ResponsiveTests.java @@ -1,4 +1,4 @@ -package web.browserInteractions; +package webPractice.browserInteractions; import com.engine.actions.BrowserActions; import org.openqa.selenium.WebDriver; diff --git a/src/test/java/web/browserInteractions/WindowsTests.java b/src/test/java/webPractice/browserInteractions/WindowsTests.java similarity index 97% rename from src/test/java/web/browserInteractions/WindowsTests.java rename to src/test/java/webPractice/browserInteractions/WindowsTests.java index d06ee5a..c9a32e8 100644 --- a/src/test/java/web/browserInteractions/WindowsTests.java +++ b/src/test/java/webPractice/browserInteractions/WindowsTests.java @@ -1,4 +1,4 @@ -package web.browserInteractions; +package webPractice.browserInteractions; import com.engine.actions.BrowserActions; import io.qameta.allure.Description; @@ -8,7 +8,7 @@ import org.openqa.selenium.By; import org.testng.Assert; import org.testng.annotations.Test; -import web.BaseTests; +import webPractice.BaseTests; @Epic("Browser Interactions") @Feature("Windows") diff --git a/src/test/java/web/capabilities/Capabilities.java b/src/test/java/webPractice/capabilities/Capabilities.java similarity index 98% rename from src/test/java/web/capabilities/Capabilities.java rename to src/test/java/webPractice/capabilities/Capabilities.java index 357c224..76595e3 100644 --- a/src/test/java/web/capabilities/Capabilities.java +++ b/src/test/java/webPractice/capabilities/Capabilities.java @@ -1,4 +1,4 @@ -package web.capabilities; +package webPractice.capabilities; import io.qameta.allure.*; import org.openqa.selenium.WebDriver; diff --git a/src/test/java/web/capabilities/SeleniumGrid.java b/src/test/java/webPractice/capabilities/SeleniumGrid.java similarity index 98% rename from src/test/java/web/capabilities/SeleniumGrid.java rename to src/test/java/webPractice/capabilities/SeleniumGrid.java index b0a2e0f..bbf1542 100644 --- a/src/test/java/web/capabilities/SeleniumGrid.java +++ b/src/test/java/webPractice/capabilities/SeleniumGrid.java @@ -1,4 +1,4 @@ -package web.capabilities; +package webPractice.capabilities; import org.openqa.selenium.By; import org.openqa.selenium.Keys; diff --git a/src/test/java/web/dataDriven/Login_ReadDataUsingExcel.java b/src/test/java/webPractice/dataDriven/Login_ReadDataUsingExcel.java similarity index 98% rename from src/test/java/web/dataDriven/Login_ReadDataUsingExcel.java rename to src/test/java/webPractice/dataDriven/Login_ReadDataUsingExcel.java index eab5f36..402bda9 100644 --- a/src/test/java/web/dataDriven/Login_ReadDataUsingExcel.java +++ b/src/test/java/webPractice/dataDriven/Login_ReadDataUsingExcel.java @@ -1,4 +1,4 @@ -package web.dataDriven; +package webPractice.dataDriven; import com.engine.dataDriven.DataProvider; import com.engine.dataDriven.ExcelFileManager; diff --git a/src/test/java/web/dataDriven/Login_ReadDataUsingJson.java b/src/test/java/webPractice/dataDriven/Login_ReadDataUsingJson.java similarity index 98% rename from src/test/java/web/dataDriven/Login_ReadDataUsingJson.java rename to src/test/java/webPractice/dataDriven/Login_ReadDataUsingJson.java index 9e46a6c..eaf02c6 100644 --- a/src/test/java/web/dataDriven/Login_ReadDataUsingJson.java +++ b/src/test/java/webPractice/dataDriven/Login_ReadDataUsingJson.java @@ -1,4 +1,4 @@ -package web.dataDriven; +package webPractice.dataDriven; import practice.gui.pages.homePage.HomePage; import practice.gui.pages.inputs.SecureAreaPage; diff --git a/src/test/java/web/elementActions/interactions/ElementActionBySelenium.java b/src/test/java/webPractice/elementActions/interactions/ElementActionBySelenium.java similarity index 98% rename from src/test/java/web/elementActions/interactions/ElementActionBySelenium.java rename to src/test/java/webPractice/elementActions/interactions/ElementActionBySelenium.java index 28d45f2..d9ebdf8 100644 --- a/src/test/java/web/elementActions/interactions/ElementActionBySelenium.java +++ b/src/test/java/webPractice/elementActions/interactions/ElementActionBySelenium.java @@ -1,8 +1,7 @@ -package web.elementActions.interactions; +package webPractice.elementActions.interactions; import com.engine.constants.FrameworkConstants; import com.engine.dataDriven.FakerData; -import com.engine.mail.GMailer; import com.engine.report.ExtentReport; import practice.gui.pages.homePage.HomePage; import practice.gui.pages.keys.KeyPressesPage; @@ -15,9 +14,8 @@ import org.openqa.selenium.Keys; import org.testng.Assert; import org.testng.annotations.Test; -import web.BaseTests; +import webPractice.BaseTests; -import java.lang.reflect.Array; import java.util.ArrayList; import static org.testng.Assert.assertEquals; diff --git a/src/test/java/web/elementActions/interactions/SelectCalendarByJSTest.java b/src/test/java/webPractice/elementActions/interactions/SelectCalendarByJSTest.java similarity index 91% rename from src/test/java/web/elementActions/interactions/SelectCalendarByJSTest.java rename to src/test/java/webPractice/elementActions/interactions/SelectCalendarByJSTest.java index b908636..cfbdc9c 100644 --- a/src/test/java/web/elementActions/interactions/SelectCalendarByJSTest.java +++ b/src/test/java/webPractice/elementActions/interactions/SelectCalendarByJSTest.java @@ -1,4 +1,4 @@ -package web.elementActions.interactions; +package webPractice.elementActions.interactions; import com.engine.actions.BrowserActions; import org.openqa.selenium.By; @@ -6,7 +6,7 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.testng.annotations.Test; -import web.BaseTests; +import webPractice.BaseTests; public class SelectCalendarByJSTest extends BaseTests { diff --git a/src/test/java/web/elementActions/interactions/UploadFileChromeOptions.java b/src/test/java/webPractice/elementActions/interactions/UploadFileChromeOptions.java similarity index 93% rename from src/test/java/web/elementActions/interactions/UploadFileChromeOptions.java rename to src/test/java/webPractice/elementActions/interactions/UploadFileChromeOptions.java index f38b783..7c417dc 100644 --- a/src/test/java/web/elementActions/interactions/UploadFileChromeOptions.java +++ b/src/test/java/webPractice/elementActions/interactions/UploadFileChromeOptions.java @@ -1,10 +1,10 @@ -package web.elementActions.interactions; +package webPractice.elementActions.interactions; import com.engine.actions.BrowserActions; import org.openqa.selenium.By; import org.openqa.selenium.chrome.ChromeOptions; import org.testng.annotations.Test; -import web.BaseTests; +import webPractice.BaseTests; import java.util.HashMap; diff --git a/src/test/java/web/elementActions/interactions/UploadFile_FireFoxOptions.java b/src/test/java/webPractice/elementActions/interactions/UploadFile_FireFoxOptions.java similarity index 92% rename from src/test/java/web/elementActions/interactions/UploadFile_FireFoxOptions.java rename to src/test/java/webPractice/elementActions/interactions/UploadFile_FireFoxOptions.java index a108ea7..c13eeb5 100644 --- a/src/test/java/web/elementActions/interactions/UploadFile_FireFoxOptions.java +++ b/src/test/java/webPractice/elementActions/interactions/UploadFile_FireFoxOptions.java @@ -1,10 +1,10 @@ -package web.elementActions.interactions; +package webPractice.elementActions.interactions; import com.engine.actions.BrowserActions; import org.openqa.selenium.By; import org.openqa.selenium.firefox.FirefoxOptions; import org.testng.annotations.Test; -import web.BaseTests; +import webPractice.BaseTests; public class UploadFile_FireFoxOptions extends BaseTests { diff --git a/src/test/java/web/elementActions/interactions/UploadFilesTest.java b/src/test/java/webPractice/elementActions/interactions/UploadFilesTest.java similarity index 95% rename from src/test/java/web/elementActions/interactions/UploadFilesTest.java rename to src/test/java/webPractice/elementActions/interactions/UploadFilesTest.java index 159bf55..08b7931 100644 --- a/src/test/java/web/elementActions/interactions/UploadFilesTest.java +++ b/src/test/java/webPractice/elementActions/interactions/UploadFilesTest.java @@ -1,10 +1,10 @@ -package web.elementActions.interactions; +package webPractice.elementActions.interactions; import practice.gui.pages.homePage.HomePage; import practice.gui.pages.uploadFilePage.FileUploadPage; import org.testng.Assert; import org.testng.annotations.Test; -import web.BaseTests; +import webPractice.BaseTests; import java.awt.*; diff --git a/src/test/java/web/elementActions/locators/FindElementBasicAndInformation.java b/src/test/java/webPractice/elementActions/locators/FindElementBasicAndInformation.java similarity index 98% rename from src/test/java/web/elementActions/locators/FindElementBasicAndInformation.java rename to src/test/java/webPractice/elementActions/locators/FindElementBasicAndInformation.java index 57484f7..6d3d3d7 100644 --- a/src/test/java/web/elementActions/locators/FindElementBasicAndInformation.java +++ b/src/test/java/webPractice/elementActions/locators/FindElementBasicAndInformation.java @@ -1,4 +1,4 @@ -package web.elementActions.locators; +package webPractice.elementActions.locators; import com.engine.actions.ElementActions; import io.qameta.allure.Description; @@ -9,7 +9,7 @@ import org.openqa.selenium.WebElement; import org.testng.annotations.*; import com.engine.actions.BrowserActions; -import web.BaseTests; +import webPractice.BaseTests; @Epic("ElementActions") @Feature("Locators") diff --git a/src/test/java/web/elementActions/locators/FindElementByAxes.java b/src/test/java/webPractice/elementActions/locators/FindElementByAxes.java similarity index 68% rename from src/test/java/web/elementActions/locators/FindElementByAxes.java rename to src/test/java/webPractice/elementActions/locators/FindElementByAxes.java index 00a11bb..09849d8 100644 --- a/src/test/java/web/elementActions/locators/FindElementByAxes.java +++ b/src/test/java/webPractice/elementActions/locators/FindElementByAxes.java @@ -1,8 +1,8 @@ -package web.elementActions.locators; +package webPractice.elementActions.locators; import io.qameta.allure.Epic; import io.qameta.allure.Feature; -import web.BaseTests; +import webPractice.BaseTests; @Epic("ElementActions") @Feature("Locators") diff --git a/src/test/java/web/elementActions/locators/FindElementByRelativeLocator.java b/src/test/java/webPractice/elementActions/locators/FindElementByRelativeLocator.java similarity index 97% rename from src/test/java/web/elementActions/locators/FindElementByRelativeLocator.java rename to src/test/java/webPractice/elementActions/locators/FindElementByRelativeLocator.java index 07381da..c7b8810 100644 --- a/src/test/java/web/elementActions/locators/FindElementByRelativeLocator.java +++ b/src/test/java/webPractice/elementActions/locators/FindElementByRelativeLocator.java @@ -1,4 +1,4 @@ -package web.elementActions.locators; +package webPractice.elementActions.locators; import com.engine.actions.BrowserActions; import com.engine.actions.ElementActions; @@ -10,7 +10,7 @@ import org.openqa.selenium.WebElement; import org.testng.Assert; import org.testng.annotations.Test; -import web.BaseTests; +import webPractice.BaseTests; @Epic("ElementActions") @Feature("Locators") diff --git a/src/test/java/web/elementActions/locators/FindElementBySeleniumRelativeLocators.java b/src/test/java/webPractice/elementActions/locators/FindElementBySeleniumRelativeLocators.java similarity index 96% rename from src/test/java/web/elementActions/locators/FindElementBySeleniumRelativeLocators.java rename to src/test/java/webPractice/elementActions/locators/FindElementBySeleniumRelativeLocators.java index 2e243fe..9c465b6 100644 --- a/src/test/java/web/elementActions/locators/FindElementBySeleniumRelativeLocators.java +++ b/src/test/java/webPractice/elementActions/locators/FindElementBySeleniumRelativeLocators.java @@ -1,4 +1,4 @@ -package web.elementActions.locators; +package webPractice.elementActions.locators; import com.engine.actions.ElementActions; import io.qameta.allure.Epic; @@ -10,7 +10,7 @@ import static org.openqa.selenium.support.locators.RelativeLocator.with; import org.testng.annotations.Test; -import web.BaseTests; +import webPractice.BaseTests; import java.util.List; diff --git a/src/test/java/web/elementActions/locators/Finders.java b/src/test/java/webPractice/elementActions/locators/Finders.java similarity index 98% rename from src/test/java/web/elementActions/locators/Finders.java rename to src/test/java/webPractice/elementActions/locators/Finders.java index 3405206..c92598a 100644 --- a/src/test/java/web/elementActions/locators/Finders.java +++ b/src/test/java/webPractice/elementActions/locators/Finders.java @@ -1,4 +1,4 @@ -package web.elementActions.locators; +package webPractice.elementActions.locators; import com.engine.actions.BrowserActions; import com.engine.actions.ElementActions; @@ -10,7 +10,7 @@ import org.openqa.selenium.WebElement; import org.testng.Assert; import org.testng.annotations.Test; -import web.BaseTests; +import webPractice.BaseTests; import java.util.List; diff --git a/src/test/java/web/elementActions/locators/MenuCount_Test.java b/src/test/java/webPractice/elementActions/locators/MenuCount_Test.java similarity index 94% rename from src/test/java/web/elementActions/locators/MenuCount_Test.java rename to src/test/java/webPractice/elementActions/locators/MenuCount_Test.java index fcc5ab6..00ac9df 100644 --- a/src/test/java/web/elementActions/locators/MenuCount_Test.java +++ b/src/test/java/webPractice/elementActions/locators/MenuCount_Test.java @@ -1,11 +1,11 @@ -package web.elementActions.locators; +package webPractice.elementActions.locators; import practice.gui.pages.homePage.HomePage; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.Test; -import web.BaseTests; +import webPractice.BaseTests; import java.util.List; diff --git a/src/test/java/web/elementActions/select/CheckBox.java b/src/test/java/webPractice/elementActions/select/CheckBox.java similarity index 98% rename from src/test/java/web/elementActions/select/CheckBox.java rename to src/test/java/webPractice/elementActions/select/CheckBox.java index 75f584f..811fc4d 100644 --- a/src/test/java/web/elementActions/select/CheckBox.java +++ b/src/test/java/webPractice/elementActions/select/CheckBox.java @@ -1,4 +1,4 @@ -package web.elementActions.select; +package webPractice.elementActions.select; import practice.gui.pages.select.CheckBoxPage; import practice.gui.pages.homePage.HomePage; diff --git a/src/test/java/web/elementActions/select/Dropdown.java b/src/test/java/webPractice/elementActions/select/Dropdown.java similarity index 98% rename from src/test/java/web/elementActions/select/Dropdown.java rename to src/test/java/webPractice/elementActions/select/Dropdown.java index 09f6476..53cf3f2 100644 --- a/src/test/java/web/elementActions/select/Dropdown.java +++ b/src/test/java/webPractice/elementActions/select/Dropdown.java @@ -1,4 +1,4 @@ -package web.elementActions.select; +package webPractice.elementActions.select; import practice.gui.pages.homePage.HomePage; import practice.gui.pages.select.DropdownPage; diff --git a/src/test/java/web/filLoginForm/Login_Test.java b/src/test/java/webPractice/filLoginForm/Login_Test.java similarity index 97% rename from src/test/java/web/filLoginForm/Login_Test.java rename to src/test/java/webPractice/filLoginForm/Login_Test.java index d258110..820d61e 100644 --- a/src/test/java/web/filLoginForm/Login_Test.java +++ b/src/test/java/webPractice/filLoginForm/Login_Test.java @@ -1,4 +1,4 @@ -package web.filLoginForm; +package webPractice.filLoginForm; import practice.gui.pages.homePage.HomePage; import practice.gui.pages.inputs.SecureAreaPage; diff --git a/src/test/java/web/filLoginForm/RegisterTest.java b/src/test/java/webPractice/filLoginForm/RegisterTest.java similarity index 97% rename from src/test/java/web/filLoginForm/RegisterTest.java rename to src/test/java/webPractice/filLoginForm/RegisterTest.java index f6181eb..ae361b2 100644 --- a/src/test/java/web/filLoginForm/RegisterTest.java +++ b/src/test/java/webPractice/filLoginForm/RegisterTest.java @@ -1,4 +1,4 @@ -package web.filLoginForm; +package webPractice.filLoginForm; import io.qameta.allure.*; import org.testng.annotations.Test; diff --git a/src/test/java/web/javaScript/JavaScriptExecutorBrowserActionsTest.java b/src/test/java/webPractice/javaScript/JavaScriptExecutorBrowserActionsTest.java similarity index 97% rename from src/test/java/web/javaScript/JavaScriptExecutorBrowserActionsTest.java rename to src/test/java/webPractice/javaScript/JavaScriptExecutorBrowserActionsTest.java index c77018e..47d7624 100644 --- a/src/test/java/web/javaScript/JavaScriptExecutorBrowserActionsTest.java +++ b/src/test/java/webPractice/javaScript/JavaScriptExecutorBrowserActionsTest.java @@ -1,4 +1,4 @@ -package web.javaScript; +package webPractice.javaScript; import com.engine.Helper; import io.qameta.allure.*; @@ -6,11 +6,11 @@ import org.openqa.selenium.JavascriptExecutor; import org.testng.annotations.Test; import com.engine.actions.BrowserActions; -import web.BaseTests; +import webPractice.BaseTests; import static org.testng.AssertJUnit.assertEquals; -@Feature("web") +@Feature("webPractice") @Epic("JavaScript Executor") public class JavaScriptExecutorBrowserActionsTest extends BaseTests { diff --git a/src/test/java/web/javaScript/JavaScriptExecutorElementActionsTest.java b/src/test/java/webPractice/javaScript/JavaScriptExecutorElementActionsTest.java similarity index 98% rename from src/test/java/web/javaScript/JavaScriptExecutorElementActionsTest.java rename to src/test/java/webPractice/javaScript/JavaScriptExecutorElementActionsTest.java index 400cede..0cb230d 100644 --- a/src/test/java/web/javaScript/JavaScriptExecutorElementActionsTest.java +++ b/src/test/java/webPractice/javaScript/JavaScriptExecutorElementActionsTest.java @@ -1,4 +1,4 @@ -package web.javaScript; +package webPractice.javaScript; import com.engine.Waits; import io.qameta.allure.*; @@ -7,7 +7,7 @@ import org.testng.Assert; import org.testng.annotations.Test; import com.engine.actions.BrowserActions; -import web.BaseTests; +import webPractice.BaseTests; import static org.testng.AssertJUnit.assertEquals; @@ -17,7 +17,7 @@ * It provides two methods such as “execute-script” & “executeAsyncScript” to run javascript on the currently * selected frame or window or page. */ -@Feature("web") +@Feature("webPractice") @Epic("JavaScript Executor") public class JavaScriptExecutorElementActionsTest extends BaseTests { diff --git a/src/test/java/web/log4j/Log4j.java b/src/test/java/webPractice/log4j/Log4j.java similarity index 93% rename from src/test/java/web/log4j/Log4j.java rename to src/test/java/webPractice/log4j/Log4j.java index 98fe540..4a4b054 100644 --- a/src/test/java/web/log4j/Log4j.java +++ b/src/test/java/webPractice/log4j/Log4j.java @@ -1,4 +1,4 @@ -package web.log4j; +package webPractice.log4j; import com.engine.actions.ElementActions; import org.apache.logging.log4j.LogManager; diff --git a/src/test/java/web/log4j/log4j2.xml b/src/test/java/webPractice/log4j/log4j2.xml similarity index 100% rename from src/test/java/web/log4j/log4j2.xml rename to src/test/java/webPractice/log4j/log4j2.xml diff --git a/src/test/java/web/sqlDatabase/SQLDatabase.java b/src/test/java/webPractice/sqlDatabase/SQLDatabase.java similarity index 95% rename from src/test/java/web/sqlDatabase/SQLDatabase.java rename to src/test/java/webPractice/sqlDatabase/SQLDatabase.java index 3399771..29f0bda 100644 --- a/src/test/java/web/sqlDatabase/SQLDatabase.java +++ b/src/test/java/webPractice/sqlDatabase/SQLDatabase.java @@ -1,4 +1,4 @@ -package web.sqlDatabase; +package webPractice.sqlDatabase; import java.sql.*; diff --git a/src/test/java/web/takeScreenShot/BrokenImages.java b/src/test/java/webPractice/takeScreenShot/BrokenImages.java similarity index 99% rename from src/test/java/web/takeScreenShot/BrokenImages.java rename to src/test/java/webPractice/takeScreenShot/BrokenImages.java index 9a5c2a1..09da3f4 100644 --- a/src/test/java/web/takeScreenShot/BrokenImages.java +++ b/src/test/java/webPractice/takeScreenShot/BrokenImages.java @@ -1,4 +1,4 @@ -package web.takeScreenShot; +package webPractice.takeScreenShot; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; diff --git a/src/test/java/web/video/recordVideo.java b/src/test/java/webPractice/video/recordVideo.java similarity index 95% rename from src/test/java/web/video/recordVideo.java rename to src/test/java/webPractice/video/recordVideo.java index 1069ab4..b92342f 100644 --- a/src/test/java/web/video/recordVideo.java +++ b/src/test/java/webPractice/video/recordVideo.java @@ -1,4 +1,4 @@ -package web.video; +package webPractice.video; import com.automation.remarks.video.annotations.Video; import org.testng.annotations.Test; diff --git a/src/test/java/web/waits/ActionsOnElements.java b/src/test/java/webPractice/waits/ActionsOnElements.java similarity index 98% rename from src/test/java/web/waits/ActionsOnElements.java rename to src/test/java/webPractice/waits/ActionsOnElements.java index fdcd82b..23f663b 100644 --- a/src/test/java/web/waits/ActionsOnElements.java +++ b/src/test/java/webPractice/waits/ActionsOnElements.java @@ -1,4 +1,4 @@ -package web.waits; +package webPractice.waits; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; diff --git a/src/test/java/web/waits/ExplicitWait.java b/src/test/java/webPractice/waits/ExplicitWait.java similarity index 98% rename from src/test/java/web/waits/ExplicitWait.java rename to src/test/java/webPractice/waits/ExplicitWait.java index eaaf4c2..22dfd0a 100644 --- a/src/test/java/web/waits/ExplicitWait.java +++ b/src/test/java/webPractice/waits/ExplicitWait.java @@ -1,4 +1,4 @@ -package web.waits; +package webPractice.waits; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; diff --git a/src/test/java/web/waits/FluentWait.java b/src/test/java/webPractice/waits/FluentWait.java similarity index 99% rename from src/test/java/web/waits/FluentWait.java rename to src/test/java/webPractice/waits/FluentWait.java index 312af5b..4244ae4 100644 --- a/src/test/java/web/waits/FluentWait.java +++ b/src/test/java/webPractice/waits/FluentWait.java @@ -1,4 +1,4 @@ -package web.waits; +package webPractice.waits; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver;