├── .gitignore ├── .idea ├── encodings.xml ├── misc.xml ├── uiDesigner.xml ├── vcs.xml └── workspace.xml ├── Files ├── Config.properties ├── Employees.xlsx └── Sales.xlsx ├── pom.xml └── src ├── Test.properties └── main └── java ├── class1 ├── E1FirstJavaProgram.java ├── E2PrintMyName.java ├── E3Variables.java ├── E4DataTypes.java ├── E5DataTypes.java ├── E6DataTypes.java ├── E7Facebook.java ├── E8Task.java ├── Notes └── TheProgrammer.java ├── class10 ├── Car.java ├── CarTester.java ├── Dog.java ├── DogTester.java ├── E10StringDemo.java ├── E11StringDemo.java ├── E1StringDemo.java ├── E2StringDemo.java ├── E3StringDemo.java ├── E4StringDemo.java ├── E5StringDemo.java ├── E6StringDemo.java ├── E7StringDemo.java ├── E8StringDemo.java ├── E9StringDemo.java ├── Notes ├── Phone.java ├── PhoneTester.java ├── Student.java └── T1Strings.java ├── class11 ├── E10StringMethods.java ├── E11StringMethods.java ├── E1StringMethods.java ├── E2StringMethods.java ├── E3StringMethods.java ├── E4StringMethods.java ├── E5MethodChaining.java ├── E5StringMethods.java ├── E6StringMethods.java ├── E7StringMethods.java ├── E8StringMethods.java ├── E9StringMethods.java ├── Notes ├── T1StringMethods.java ├── T2StringMethods.java └── T3StringMethods.java ├── class12 ├── Calculator.java ├── E1Methods.java ├── E2CalculatorTester.java ├── E2Methods.java ├── E2MethodsTester.java ├── E3StringVsStringBuilder.java ├── E4StringVsStringBuilder.java ├── E5Practice.java ├── Notes ├── T1Methods.java ├── T1Tester.java ├── T2Methods.java └── T2MethodsTester.java ├── class13 ├── Dog.java ├── DogTester.java ├── E1LocalVariables.java ├── E2InstanceVariables.java ├── E2InstanceVariablesTester.java ├── E3LocalDemo.java ├── E3Tester.java ├── E4StringBuilder.java ├── MathConstants.java ├── Notes ├── OtherClass.java └── SyntaxEmployee.java ├── class14 ├── BankAccount.java ├── BankTester.java ├── Notes ├── T1ReverseWord.java ├── T2.java ├── T3.java └── T4.java ├── class15 ├── Car.java ├── CarTester.java ├── ConTesterTesterDifferentPkg.java ├── Dog.java ├── DogTester.java ├── Notes ├── Repl.java ├── SeleniumDemo.java ├── Student.java ├── StudentTester.java ├── T1.java └── Test.java ├── class16 ├── Cat.java ├── CatTester.java ├── ConTester.java ├── ConTesterTester.java ├── Notes ├── Person.java ├── PersonTester.java ├── Student.java └── StudentTester.java ├── class17 ├── A.java ├── Animal.java ├── AnimalTester.java ├── Cat.java ├── CatDog.java ├── Dee.java ├── Dog.java ├── HondaBike.java ├── MultiLevelTester.java ├── Notes ├── X.java └── teacher.java ├── class18 ├── Bike.java ├── Car.java ├── CarTester.java ├── Furniture.java ├── GrandParent.java ├── Notes ├── Shape.java └── User.java ├── class19 ├── Ali.java ├── Animal.java ├── AnimalTester.java ├── Calculator.java ├── CalculatorTester.java ├── CreditCard.java ├── CreditCardTester.java ├── Degree.java ├── Note ├── Programming.java ├── T1.java ├── T1Tester.java └── T2.java ├── class2 ├── E10ShorthandOperators.java ├── E11ShorthandOperators.java ├── E12ShorthandOperators.java ├── E13ShorthandOperators.java ├── E14ShorthandOperators.java ├── E1Variables.java ├── E2StringDemo.java ├── E3StringConCatDemo.java ├── E4StringConcat.java ├── E5ArithmeticOperator.java ├── E6ArithmeticOperators.java ├── E7ArithmeticOperators.java ├── E8ArithmeticOperators.java ├── E8StringConcat.java ├── E9ArithmeticOperators.java ├── E9StringConcat.java ├── T1PracticeVariables.java ├── T2VariableValues.java ├── T3Variables.java ├── T4.java └── T5Square.java ├── class20 ├── Ambient-music-free.mp3 ├── Animal.java ├── AnimalTester.java ├── E1Drawing.java ├── E2AudioPlayer.java ├── E3TypesCasting.java ├── E4PolyMor.java ├── E5Selenium.java ├── E5SeleniumProfessional.java ├── E6CreatingFiles.java ├── E7Final.java ├── Notes ├── Student.java └── Student1.java ├── class21 ├── Animal.java ├── AnimalTester.java ├── E1.java ├── File.java ├── FileTester.java ├── Notes ├── WebDriver.java └── WebDriverTester.java ├── class22 ├── ABSTester.java ├── BikeTester.java ├── E1Interfaces.java ├── MoveAble.java ├── MoveAbleTester.java ├── Notes.txt ├── Vehicle.java └── WebDriverTester.java ├── class23 ├── BankAccount.java ├── BankAccountTester.java ├── E1CollectionsFramework.java ├── E2ArrayList.java ├── E3ArrayList.java ├── E4ArrayList.java ├── Notes ├── Registration.java ├── RegistrationTester.java └── User.java ├── class24 ├── E1ArrayList.java ├── E2ArrayList.java ├── E3ArrayList.java ├── E4ArrayList.java ├── E5BoxingUnBoxing.java ├── E6.java ├── Notes ├── T1.java ├── T2.java ├── T3.java ├── T4.java └── T5.java ├── class25 ├── E10.java ├── E1ArrayList.java ├── E1Sets.java ├── E2ArrayList.java ├── E3ArrayList.java ├── E4ArrayListVsLinkedList.java ├── E5ArrayListVsLinkedList.java ├── E6LinkedList.java ├── E7Sets.java ├── E8Sets.java ├── E9Set.java ├── Notes ├── T1ArrayList.java ├── T2ArrayList.java ├── T3Sets.java └── T4Sets.java ├── class26 ├── E10Maps.java ├── E11Maps.java ├── E1Maps.java ├── E2Maps.java ├── E3Maps.java ├── E4Maps.java ├── E5Maps.java ├── E6Maps.java ├── E7Maps.java ├── E8Maps.java ├── E9Maps.java ├── Notes ├── Q6.java ├── T1Maps.java ├── T2Maps.java └── T3Maps.java ├── class27 ├── E1ConfigReader.java ├── E2ConfigProperties.java ├── E3ConfigProperties.java ├── E4ExcelFile.java └── Notes ├── class28 ├── E1ExcelFile.java ├── E2ListOfMaps.java ├── E3ExcelFile.java ├── ExcelReaderTester.java └── Notes ├── class29 ├── E10Exceptions.java ├── E11Exceptions.java ├── E1Exceptions.java ├── E2Exceptions.java ├── E3Exceptions.java ├── E4Exceptions.java ├── E5Exceptions.java ├── E6Exceptions.java ├── E7Exceptions.java ├── E8Exceptions.java ├── E9Exceptions.java └── Notes ├── class3 ├── E10ElseIf.java ├── E1TypeCasting.java ├── E2TypeCasting.java ├── E3TypeCasting.java ├── E4RelationalOperators.java ├── E5RelationalOperators.java ├── E6IfElseStatements.java ├── E7IfElseStatements.java ├── E8IfElseStatements.java ├── E9ElseIfStatements.java ├── Notes ├── T1DoubleComparison.java ├── T2TemperatureCheck.java ├── T3.java └── T4.java ├── class4 ├── Debugger.java ├── E1IfElseStatements.java ├── E2NestedIf.java ├── E3NestedIfElse.java ├── E4Scanner.java ├── E5Scanner.java ├── E6Scanner.java ├── E7Scanner.java ├── E8Scanner.java ├── Notes ├── T1.java └── T2.java ├── class5 ├── E10Switch.java ├── E11Switch.java ├── E1NotOperator.java ├── E2NotOperator.java ├── E3NotOperator.java ├── E4OROperator.java ├── E5OROperator.java ├── E6OROperator.java ├── E7ANDOperator.java ├── E8ANDOperator.java ├── E9ANDOperator.java ├── Notes ├── StaticTester.java ├── T1OROperator.java ├── T2ANDOperator.java ├── T3ANDOROperator.java ├── T4LogicalOperators.java └── T5Switch.java ├── class6 ├── E10WhileLoop.java ├── E11DoWhileLoop.java ├── E12DoWhileLoop.java ├── E13DoWhileLoop.java ├── E14ForLoop.java ├── E1IncrementOperators.java ├── E2IncrementOperators.java ├── E3WhileLoop.java ├── E4WhileLoop.java ├── E5WhileLoop.java ├── E6WhileLoop.java ├── E7WhileLoop.java ├── E8WhileLoop.java ├── E9WhileLoop.java ├── Notes ├── T10ForLoop.java ├── T11ForLoop.java ├── T1WhileLoop.java ├── T2WhileLoop.java ├── T3WhileLoop.java ├── T4WhileLoop.java ├── T5WhileLoop.java ├── T6WhileLoop.java ├── T7DoWhileLoop.java ├── T8ForLoop.java └── T9ForLoop.java ├── class7 ├── E10Arrays.java ├── E11Arrays.java ├── E1NestedLoops.java ├── E2NestedLoops.java ├── E3NestedLoops.java ├── E4NestedLoops.java ├── E5NestedLoops.java ├── E6NestedLoops.java ├── E7Arrays.java ├── E8Arrays.java ├── E9Arrays.java ├── Notes ├── T1NestedLoops.java ├── T2NestedLoops.java ├── T3NestedLoops.java ├── T4NestedLoops.java ├── T5NestedLoops.java ├── T6Arrays.java ├── T7Arrays.java └── T8Arrays.java ├── class8 ├── E10ContinueKeyword.java ├── E1Arrays.java ├── E2Arrays.java ├── E3EnhancedLoop.java ├── E4EnhancedLoop.java ├── E5EnhancedLoop.java ├── E6EnhancedLoop.java ├── E7BreakKeyword.java ├── E8BreakKeyword.java ├── E9BreakKeyword.java ├── Notes ├── T1Arrays.java ├── T2Arrays.java ├── T3Arrays.java ├── T4EnhancedLoop.java ├── T5EnhancedLoop.java ├── T6EnhancedLoop.java └── T7EnhancedLoop.java ├── class9 ├── E12DArrays.java ├── E22DArrays.java ├── E32DArrays.java ├── E42DArrays.java ├── E52DArrays.java ├── E62DArrays.java ├── E72DArrays.java ├── E82DArrays.java ├── E92DArrays.java ├── Notes ├── T12DArrays.java ├── T22DArrays.java ├── T32DArrays.java └── T42DArray.java ├── review1 ├── E1Variables.java ├── E2Variables.java ├── E3Variables.java ├── E4ShortHandOperators.java ├── E5ShortHandOperators.java ├── Notes └── T1Variables.java ├── review10 ├── Animal.java ├── AnimalTester.java ├── Car.java ├── Human.java ├── Notes ├── Q5.java └── WashAble.java ├── review11 ├── E1WrapperClasses.java ├── E2ArrayList.java ├── E3ArrayList.java ├── E4ArrayList.java ├── E5ArrayList.java ├── E6ArrayList.java ├── E7ArrayList.java ├── E8ArrayList.java └── Notes ├── review12 ├── E1ArrayListVsLinkedList.java ├── E2Sets.java ├── E3Maps.java ├── E4Maps.java ├── E5Maps.java ├── E6Maps.java ├── Human.java ├── MethodTester.java ├── Methods.java └── Notes ├── review13 ├── Account.java ├── E1File.java ├── E2Config.java ├── E3Config.java ├── E4ExcelFiles.java ├── E5Excel.java ├── E6Exceptions.java ├── InsufficientAccountBalanceException.java └── Notes.txt ├── review2 ├── E1TypeCasting.java ├── E2IfStatements.java ├── E3IfElseStatements.java ├── E4IfElseScanner.java ├── E5IfElseScanner.java ├── E6IfIFDemo.java ├── E7CommonScannerIssues.java ├── E7NestedIf.java ├── E8CommonScannerIssues.java └── Notes ├── review3 ├── E1LogicalOperators.java ├── E2LogicalOperators.java ├── E3Switch.java ├── E4Switch.java ├── E5Switch.java ├── E6WhileLoop.java ├── E7DoWhile.java ├── E8ForLoop.java ├── E9ForLoop.java ├── Notes ├── T1LogicalOperators.java └── T2WhileLoop.java ├── review4 ├── E1NestedLoop.java ├── E2NestedLoop.java ├── E3NestedLoop.java ├── E4NestedLoop.java ├── E5NestedLoop.java ├── E6Arrays.java ├── E7Arrays.java ├── E8Arrays.java ├── E9Arrays.java ├── Notes └── Repl67.java ├── review5 ├── AnotherReview.java ├── ArrayReview.java ├── LoopsRecap.java ├── TwoDArray.java └── TwoDArrayExample.java ├── review6 ├── E1StringMethods.java ├── E2StringMethods.java ├── E3StringMethods.java └── Notes ├── review7 ├── Book.java ├── Store.java ├── StringOverview.java └── Superheroes.java ├── review8 ├── Car.java ├── Dog.java ├── E1LocalVariables.java ├── E2InstanceVar.java ├── E3StaticVar.java └── Notes ├── review9 ├── Animal.java ├── AnimalTester.java ├── Calculator.java ├── CalculatorTester.java ├── Main.java ├── Main2.java ├── Notes ├── Parent.java ├── ParentTester.java ├── Printer.java └── PrinterTester.java └── utils ├── ConfigReader.java ├── Constants.java └── ExcelReader.java /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Files/Config.properties: -------------------------------------------------------------------------------- 1 | userName=Admin 2 | password=Hum@nhrm123 3 | URL=http://hrm.syntaxtechs.net/humanresources/symfony/web/index.php/dashboard 4 | browser=chrome -------------------------------------------------------------------------------- /Files/Employees.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SyntaxTechnologies/SDETBatch17/568a3c49224a4a8f9ee55520f650458f73532cc5/Files/Employees.xlsx -------------------------------------------------------------------------------- /Files/Sales.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SyntaxTechnologies/SDETBatch17/568a3c49224a4a8f9ee55520f650458f73532cc5/Files/Sales.xlsx -------------------------------------------------------------------------------- /src/Test.properties: -------------------------------------------------------------------------------- 1 | name=Ehab -------------------------------------------------------------------------------- /src/main/java/class1/E1FirstJavaProgram.java: -------------------------------------------------------------------------------- 1 | package class1; 2 | 3 | public class E1FirstJavaProgram { 4 | 5 | public static void main(String[] args) { 6 | System.out.println("Hello World"); 7 | //11:50 8 | } 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/class1/E2PrintMyName.java: -------------------------------------------------------------------------------- 1 | package class1; 2 | 3 | public class E2PrintMyName { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println("Hello Asghar"); 8 | } 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/class1/E3Variables.java: -------------------------------------------------------------------------------- 1 | package class1; 2 | 3 | public class E3Variables { 4 | public static void main(String[] args) { 5 | // byte->data type which tells the computer what type of information 6 | // we are going to store 7 | 8 | /* 9 | age-> variable/container/box/label 10 | = -> this sign is used to store something in a variable/container/box/label 11 | 16 -> the value that we want to store in age 12 | */ 13 | byte age=16; 14 | System.out.println(age); 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/class1/E4DataTypes.java: -------------------------------------------------------------------------------- 1 | package class1; 2 | 3 | public class E4DataTypes { //PascalCase 4 | public static void main(String[] args) { 5 | 6 | byte age=127; 7 | short iphonePrice=1099; // camelCase 8 | int bankBalance=3200000; //most widely used 9 | long distance=1112255144555525L; 10 | System.out.println(age); 11 | System.out.println(iphonePrice); 12 | System.out.println(bankBalance); 13 | System.out.println(distance); 14 | 15 | // Break till 1:50 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/class1/E5DataTypes.java: -------------------------------------------------------------------------------- 1 | package class1; 2 | 3 | public class E5DataTypes { 4 | public static void main(String[] args) { 5 | 6 | float price=12.235555556622522116552999999F; 7 | double pi=3.1452645582541215599999999999; //most widely used 8 | System.out.println(price); 9 | System.out.println(pi); 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/class1/E6DataTypes.java: -------------------------------------------------------------------------------- 1 | package class1; 2 | 3 | public class E6DataTypes { 4 | public static void main(String[] args) { 5 | char gender='M'; 6 | System.out.println(gender); 7 | 8 | boolean isRaining=false; 9 | boolean isHungry=true; 10 | boolean wife=true; 11 | boolean husband=false; 12 | 13 | char symbol='!'; 14 | 15 | String name="Aman"; 16 | System.out.println(name); 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/class1/E7Facebook.java: -------------------------------------------------------------------------------- 1 | package class1; 2 | 3 | public class E7Facebook { 4 | public static void main(String[] args) { 5 | 6 | String firstName="Mel"; 7 | String surName="Arc"; 8 | String mobileNumber="+1352-564-7885"; 9 | String password="1345sdsd"; 10 | int day=22; 11 | String month="Jul"; 12 | int year=2022; 13 | String gender="Female"; 14 | // same name variables are not allowed 15 | // String gender="male"; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/class1/E8Task.java: -------------------------------------------------------------------------------- 1 | package class1; 2 | 3 | public class E8Task { 4 | /* 5 | create variables and store your 6 | name 7 | age 8 | city 9 | salary 10 | country 11 | print this info as well 12 | */ 13 | 14 | public static void main(String[] args) { 15 | 16 | String name="Hind"; 17 | int age=16; 18 | String city="New York"; 19 | String salary="$120,000"; 20 | String country="USA"; 21 | System.out.println(name); 22 | System.out.println(); 23 | System.out.println(age); 24 | System.out.println(city); 25 | System.out.println(salary); 26 | System.out.println(country); 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/class1/TheProgrammer.java: -------------------------------------------------------------------------------- 1 | package class1; 2 | 3 | public class TheProgrammer { 4 | public static void main(String[] args) { 5 | System.out.println("This is my third Java Program"); 6 | System.out.println("I am a Java Programmer"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/class10/Car.java: -------------------------------------------------------------------------------- 1 | package class10; 2 | 3 | public class Car { 4 | String make; 5 | String model; 6 | double price; 7 | 8 | void moveForward(){ 9 | System.out.println("Moving forward"); 10 | } 11 | void applyBrakes(){ 12 | System.out.println("Applying the brakes"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/class10/CarTester.java: -------------------------------------------------------------------------------- 1 | package class10; 2 | 3 | public class CarTester { 4 | public static void main(String[] args) { 5 | Car bmw=new Car(); 6 | bmw.make="BMW"; 7 | bmw.model="I7"; 8 | bmw.price=100000; 9 | bmw.moveForward(); 10 | bmw.applyBrakes(); 11 | 12 | // Break till 1:48 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/class10/Dog.java: -------------------------------------------------------------------------------- 1 | package class10; 2 | 3 | public class Dog { 4 | String name; 5 | String breed; 6 | char gender; 7 | int age; 8 | double weight; 9 | 10 | void eat(){ 11 | System.out.println("Eating meat and bones..."); 12 | } 13 | 14 | void bark(){ 15 | System.out.println("woff woff....."); 16 | } 17 | void sleep(){ 18 | System.out.println("ZZZzzzZZZzzzzz.."); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/class10/E10StringDemo.java: -------------------------------------------------------------------------------- 1 | package class10; 2 | 3 | public class E10StringDemo { 4 | public static void main(String[] args) { 5 | 6 | String str="Today is a java Class"; 7 | System.out.println(str.contains("java")); 8 | System.out.println(str.contains("Python")); 9 | System.out.println(str.contains("a")); 10 | System.out.println(str.contains("b")); //Ctrl+D 11 | 12 | 13 | 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class10/E11StringDemo.java: -------------------------------------------------------------------------------- 1 | package class10; 2 | 3 | public class E11StringDemo { 4 | public static void main(String[] args) { 5 | 6 | String name = "James"; 7 | String name2 = "JAmes"; 8 | System.out.println(name.equals(name2)); 9 | System.out.println(name.equalsIgnoreCase(name2)); 10 | 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/class10/E1StringDemo.java: -------------------------------------------------------------------------------- 1 | package class10; 2 | 3 | public class E1StringDemo { 4 | public static void main(String[] args) { 5 | //we have crated an object from the String class and have stored 6 | //Cat inside it. 7 | String obj=new String("Cat"); 8 | // Shortcut to create objs from String class 9 | String obj2="My Dog"; // String obj2=new String("Dog") 10 | int len=obj2.length(); // calling the length method/function/action/behaviour 11 | System.out.println(len); 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/class10/E2StringDemo.java: -------------------------------------------------------------------------------- 1 | package class10; 2 | 3 | public class E2StringDemo { 4 | public static void main(String[] args) { 5 | 6 | String name="Madina @#"; 7 | 8 | if(name.length()<8){ 9 | System.out.println("Name not allowed"); 10 | } 11 | 12 | System.out.println(name.length()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/class10/E3StringDemo.java: -------------------------------------------------------------------------------- 1 | package class10; 2 | 3 | public class E3StringDemo { 4 | public static void main(String[] args) { 5 | 6 | String name="MADINA"; 7 | 8 | System.out.println(name.toLowerCase()); 9 | System.out.println(name); 10 | name=name.toLowerCase(); // reassigning the contents in the name variable 11 | System.out.println(name); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/class10/E4StringDemo.java: -------------------------------------------------------------------------------- 1 | package class10; 2 | 3 | public class E4StringDemo { 4 | public static void main(String[] args) { 5 | 6 | String name="Madina"; 7 | System.out.println(name.toUpperCase()); 8 | 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/class10/E5StringDemo.java: -------------------------------------------------------------------------------- 1 | package class10; 2 | 3 | public class E5StringDemo { 4 | public static void main(String[] args) { 5 | 6 | String name="Artur"; 7 | String name2="Madina"; 8 | String fullName=name2.concat(name); 9 | System.out.println(fullName); 10 | System.out.println(name2+name); // Mostly this is used 11 | 12 | 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/class10/E6StringDemo.java: -------------------------------------------------------------------------------- 1 | package class10; 2 | 3 | public class E6StringDemo { 4 | public static void main(String[] args) { 5 | 6 | String name="Artur"; 7 | String name2="Madina"; 8 | String fullName=name2.concat(name); 9 | System.out.println(fullName); 10 | System.out.println(name2+name); // Mostly this is used 11 | 12 | 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/class10/E7StringDemo.java: -------------------------------------------------------------------------------- 1 | package class10; 2 | 3 | public class E7StringDemo { 4 | public static void main(String[] args) { 5 | 6 | String name=""; 7 | boolean is=name.isEmpty(); 8 | System.out.println(is); 9 | 10 | 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/class10/E8StringDemo.java: -------------------------------------------------------------------------------- 1 | package class10; 2 | 3 | public class E8StringDemo { 4 | public static void main(String[] args) { 5 | 6 | String name=" USA "; 7 | System.out.println(name); 8 | // Going to remove all the spaces before and after the String 9 | System.out.println(name.trim()); 10 | 11 | 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/class10/E9StringDemo.java: -------------------------------------------------------------------------------- 1 | package class10; 2 | 3 | public class E9StringDemo { 4 | public static void main(String[] args) { 5 | 6 | String str="Today is a java Class"; 7 | System.out.println(str.startsWith("T")); 8 | System.out.println(str.startsWith(" Today")); 9 | System.out.println(str.endsWith("s")); 10 | System.out.println(str.endsWith("Class")); 11 | 12 | 13 | 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class10/Phone.java: -------------------------------------------------------------------------------- 1 | package class10; 2 | 3 | public class Phone { 4 | String make; 5 | String model; 6 | double price; 7 | String os; 8 | 9 | void call(){ 10 | System.out.println("Calling Syntax......"); 11 | } 12 | 13 | void sendText(){ 14 | System.out.println("Sending text......"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class11/E10StringMethods.java: -------------------------------------------------------------------------------- 1 | package class11; 2 | 3 | public class E10StringMethods { 4 | public static void main(String[] args) { 5 | //String str = "Hi#There#how#are#you"; 6 | String str = "Hi There how are you"; 7 | String [] strArr=str.split(" "); 8 | System.out.println(strArr.length); 9 | System.out.println(strArr[1]); 10 | 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/class11/E11StringMethods.java: -------------------------------------------------------------------------------- 1 | package class11; 2 | 3 | public class E11StringMethods { 4 | public static void main(String[] args) { 5 | String str="United States Of Uganda"; 6 | char [] arr=str.toCharArray(); 7 | for (char c:arr){ 8 | System.out.println(c); 9 | } 10 | 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/class11/E1StringMethods.java: -------------------------------------------------------------------------------- 1 | package class11; 2 | 3 | public class E1StringMethods { 4 | public static void main(String[] args) { 5 | 6 | String str="Batch 17 is great."; 7 | 8 | System.out.println(str.charAt(0)); 9 | System.out.println(str.charAt(4)); 10 | int length=str.length(); 11 | System.out.println(length); 12 | 13 | System.out.println(str.charAt(str.length()-1)); 14 | System.out.println("***********************"); 15 | int lastIndex=str.length()-1; 16 | // System.out.println(lastIndex); 17 | char c=str.charAt(lastIndex); 18 | System.out.println(c); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/class11/E2StringMethods.java: -------------------------------------------------------------------------------- 1 | package class11; 2 | 3 | public class E2StringMethods { 4 | public static void main(String[] args) { 5 | // write code that will count how many times the letter a has appeared in the 6 | //String 7 | String str="Batch 17 is A great batch. Just Kidding. Please don't take it seriously"; 8 | int count=0; 9 | for (int i = 0; i < str.length(); i++) { 10 | if(str.charAt(i)=='a'|| str.charAt(i)=='A'){ 11 | count++; 12 | } 13 | } 14 | System.out.println(count); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class11/E3StringMethods.java: -------------------------------------------------------------------------------- 1 | package class11; 2 | 3 | public class E3StringMethods { 4 | public static void main(String[] args) { 5 | 6 | String str="sdrg#$%4575"; 7 | System.out.println(str.indexOf('s')); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/class11/E4StringMethods.java: -------------------------------------------------------------------------------- 1 | package class11; 2 | 3 | public class E4StringMethods { 4 | public static void main(String[] args) { 5 | 6 | String str="Batch 17 is A great batch. Just Kidding. Please don't take it seriously"; 7 | // Break till 11:53 8 | String subStr=str.substring(0,4); 9 | System.out.println(subStr); 10 | 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/class11/E5MethodChaining.java: -------------------------------------------------------------------------------- 1 | package class11; 2 | 3 | public class E5MethodChaining { 4 | public static void main(String[] args) { 5 | 6 | 7 | String str=" Batch 17 IS GREAT. "; 8 | System.out.println(str.toLowerCase().trim().replace("great","Good")); 9 | // System.out.println(str.toLowerCase().isEmpty().replace("great","Good")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/class11/E5StringMethods.java: -------------------------------------------------------------------------------- 1 | package class11; 2 | 3 | public class E5StringMethods { 4 | public static void main(String[] args) { 5 | String str="Batch 17 is good. They are doing good"; 6 | String newStr=str.replace("good","great"); 7 | System.out.println(newStr); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/class11/E6StringMethods.java: -------------------------------------------------------------------------------- 1 | package class11; 2 | 3 | public class E6StringMethods { 4 | public static void main(String[] args) { 5 | 6 | String str="ks d nfjA ZSX232 98 ()4!@# %^&A S"; 7 | System.out.println(str.replaceAll("[A-Z]","=")); 8 | System.out.println(str.replaceAll("[A-C]","=")); 9 | System.out.println(str.replaceAll("[a-z]","=")); 10 | System.out.println(str.replaceAll("[0-9]","")); 11 | System.out.println(str.replaceAll("[&-;]","")); 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/class11/E8StringMethods.java: -------------------------------------------------------------------------------- 1 | package class11; 2 | 3 | public class E8StringMethods { 4 | public static void main(String[] args) { 5 | String str = "Hi There how are you.I am Good. I am Driving"; 6 | String[] strs = str.split("[.]"); 7 | // System.out.println(strs.length); 8 | System.out.println(strs[2]); 9 | System.out.println(strs[2].trim()); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/class11/E9StringMethods.java: -------------------------------------------------------------------------------- 1 | package class11; 2 | 3 | public class E9StringMethods { 4 | public static void main(String[] args) { 5 | String str = "Hi There how are you.I am Good. I am Driving"; 6 | String[] strs = str.split("[.\\s]"); 7 | // String[] strs = str.split("[\\s]"); 8 | System.out.println(strs.length); 9 | // System.out.println(strs[4]); 10 | for (String s:strs){ 11 | System.out.println(s); 12 | } 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/class11/T1StringMethods.java: -------------------------------------------------------------------------------- 1 | package class11; 2 | /* 3 | Create a String and if the String is not empty perform the following: 4 | if the String has an odd number of characters and has 3 or more characters, 5 | print the character in the middle of the String. 6 | For Example String str=hello =>l 7 | 8 | */ 9 | public class T1StringMethods { 10 | public static void main(String[] args) { 11 | String str="ada"; 12 | 13 | 14 | if(str.length()%2!=0&&str.length()>=3){ 15 | int middle=str.length()/2; 16 | System.out.println(str.charAt(middle)); 17 | } 18 | 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/class11/T2StringMethods.java: -------------------------------------------------------------------------------- 1 | package class11; 2 | /* 3 | Create a String and print it in reverse order (Sunday → yadnuS). 4 | */ 5 | public class T2StringMethods { 6 | public static void main(String[] args) { 7 | 8 | String str="Sunday"; 9 | // System.out.println("yadnus"); 10 | String reversed=""; 11 | for (int i = str.length()-1; i >=0 ; i--) { 12 | reversed=reversed+str.charAt(i); 13 | } 14 | System.out.println(reversed); 15 | 16 | 17 | 18 | 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/class11/T3StringMethods.java: -------------------------------------------------------------------------------- 1 | package class11; 2 | /* 3 | Create a String and print it in reverse order (Sunday → yadnuS). 4 | */ 5 | public class T3StringMethods { 6 | public static void main(String[] args) { 7 | String str="Hi There how are you@#@%. I am Good. How are you?"; 8 | System.out.println(str.replaceAll("[@#%]","")); 9 | 10 | 11 | 12 | 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/class12/E1Methods.java: -------------------------------------------------------------------------------- 1 | package class12; 2 | 3 | import java.util.Scanner; 4 | 5 | public class E1Methods { 6 | public static void main(String[] args) { 7 | 8 | takeUserInput(); 9 | System.out.println("Please enter the details again"); 10 | takeUserInput(); 11 | } 12 | 13 | 14 | static void takeUserInput(){ 15 | Scanner scanner = new Scanner(System.in); 16 | System.out.println("Please Enter your name"); 17 | String name = scanner.nextLine(); 18 | System.out.println("Please Enter your age"); 19 | int age = scanner.nextInt(); 20 | System.out.println("Your name is " + name + " and you are " + age + " years old"); 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/class12/E2CalculatorTester.java: -------------------------------------------------------------------------------- 1 | package class12; 2 | 3 | public class E2CalculatorTester { 4 | public static void main(String[] args) { 5 | // we have created the object of the 6 | // Calculator class 7 | Calculator calc=new Calculator(); 8 | // to call the method using the object of the class 9 | // calc.add(); 10 | //calc.subtract(); 11 | calc.multiply(20,20); 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/class12/E2Methods.java: -------------------------------------------------------------------------------- 1 | package class12; 2 | 3 | public class E2Methods { 4 | 5 | int add(int num1,int num2){ 6 | int result=num1+num2; 7 | 8 | return result; 9 | } 10 | 11 | // create a method which takes a number multiply it with 10 12 | // and returns the result 13 | 14 | int multiply(int num){ 15 | int res=num*10; 16 | return res; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/class12/E2MethodsTester.java: -------------------------------------------------------------------------------- 1 | package class12; 2 | 3 | public class E2MethodsTester { 4 | public static void main(String[] args) { 5 | 6 | E2Methods e2 = new E2Methods(); 7 | int sum = e2.add(10, 10); 8 | System.out.println(sum); 9 | /*Scanner scanner = new Scanner(System.in); 10 | int age = scanner.nextInt();*/ 11 | 12 | int results= e2.multiply(20); 13 | System.out.println(results); 14 | // Break till 1:48 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class12/E3StringVsStringBuilder.java: -------------------------------------------------------------------------------- 1 | package class12; 2 | 3 | public class E3StringVsStringBuilder { 4 | public static void main(String[] args) { 5 | String name="Baber"; 6 | name.toLowerCase(); 7 | System.out.println(name); 8 | 9 | StringBuilder sb=new StringBuilder("Sunday"); 10 | sb.reverse(); 11 | System.out.println(sb); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/class12/E4StringVsStringBuilder.java: -------------------------------------------------------------------------------- 1 | package class12; 2 | 3 | public class E4StringVsStringBuilder { 4 | public static void main(String[] args) { 5 | 6 | String name1,name2,name3,name4; 7 | name1="United states of America"; 8 | name2="United states of America"; 9 | name3="United states of America"; 10 | name4="United states of America"; 11 | 12 | StringBuilder sb=new StringBuilder("Sunday"); 13 | StringBuffer sf=new StringBuffer("Sunday"); 14 | sb.reverse(); 15 | sf.reverse(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/class12/E5Practice.java: -------------------------------------------------------------------------------- 1 | package class12; 2 | 3 | import org.openqa.selenium.chrome.ChromeDriver; 4 | 5 | public class E5Practice { 6 | public static void main(String[] args) { 7 | 8 | ChromeDriver chromeDriver=new ChromeDriver(); 9 | //chromeDriver.get("https://google.com"); 10 | chromeDriver.get("https://amazon.com"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/class12/T1Methods.java: -------------------------------------------------------------------------------- 1 | package class12; 2 | 3 | /* 4 | Create a method that will take 2 parameters as a numbers and 5 | prints which number is larger. 6 | */ 7 | public class T1Methods { 8 | 9 | void printLarger(int num1,int num2){ 10 | 11 | if(num1>num2){ 12 | System.out.println("Larger number is "+num1); 13 | }else { 14 | System.out.println("Larger number is "+num2); 15 | } 16 | } 17 | 18 | /* 19 | Create a method that will take a number and prints whether 20 | the number is even or odd. 21 | */ 22 | void checkEvenOdd(int num){ 23 | 24 | if(num%2==0){ 25 | System.out.println(num+" is an even number"); 26 | }else { 27 | System.out.println(num+" is an odd number"); 28 | } 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/class12/T1Tester.java: -------------------------------------------------------------------------------- 1 | package class12; 2 | 3 | public class T1Tester { 4 | public static void main(String[] args) { 5 | 6 | T1Methods obj=new T1Methods(); 7 | obj.printLarger(100,20); 8 | 9 | obj.checkEvenOdd(10); 10 | 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/class12/T2MethodsTester.java: -------------------------------------------------------------------------------- 1 | package class12; 2 | 3 | public class T2MethodsTester { 4 | public static void main(String[] args) { 5 | T2Methods t2 = new T2Methods(); 6 | System.out.println(t2.getLarger(10, 20)); 7 | 8 | System.out.println(t2.createEmail("Uziar", 9 | "Baber", "gmail")); 10 | } 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/class13/Dog.java: -------------------------------------------------------------------------------- 1 | package class13; 2 | 3 | public class Dog { 4 | String name; 5 | String breed; 6 | int age; 7 | 8 | void printInfo(){ 9 | System.out.println(name+" "+breed+" "+age); 10 | } 11 | 12 | void printName(){ 13 | System.out.println(name); 14 | } 15 | 16 | void changeName(String dogName){ 17 | name=dogName; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/class13/DogTester.java: -------------------------------------------------------------------------------- 1 | package class13; 2 | 3 | public class DogTester { 4 | public static void main(String[] args) { 5 | 6 | Dog d1=new Dog(); 7 | d1.name="Picho"; 8 | d1.breed="Persian"; 9 | d1.age=36; 10 | 11 | Dog d2=new Dog(); 12 | d2.name="Papi"; 13 | d2.breed="German"; 14 | d2.age=21; 15 | d1.printInfo(); 16 | d2.printInfo(); 17 | 18 | System.out.println(SyntaxEmployee.CEO); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/class13/E1LocalVariables.java: -------------------------------------------------------------------------------- 1 | package class13; 2 | 3 | public class E1LocalVariables { 4 | String country="USA"; 5 | public static void main(String[] args) { 6 | 7 | String name="Java"; 8 | 9 | if(10>5){ 10 | int age=23; 11 | System.out.println(name); 12 | System.out.println(age); 13 | } 14 | 15 | // System.out.println(age); 16 | System.out.println(name); 17 | 18 | 19 | } 20 | 21 | int salary=120000; 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/class13/E2InstanceVariables.java: -------------------------------------------------------------------------------- 1 | package class13; 2 | 3 | public class E2InstanceVariables { 4 | String name="Hind"; 5 | 6 | void printAge(){ 7 | int age=25; 8 | System.out.println(age); 9 | System.out.println(name); 10 | System.out.println(country); 11 | 12 | } 13 | void printCountry(){ 14 | // System.out.println(age); error its a local variable can't be accessed here 15 | System.out.println(name); 16 | System.out.println(country); 17 | if(10>5){ 18 | System.out.println(country); 19 | } 20 | } 21 | 22 | static String country="Uganda"; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/class13/E2InstanceVariablesTester.java: -------------------------------------------------------------------------------- 1 | package class13; 2 | 3 | public class E2InstanceVariablesTester { 4 | public static void main(String[] args) { 5 | 6 | 7 | System.out.println("Line1"); 8 | System.out.println(E2InstanceVariables.country); 9 | System.out.println(); 10 | 11 | E2InstanceVariables e2=new E2InstanceVariables(); 12 | e2.printAge(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/class13/E3LocalDemo.java: -------------------------------------------------------------------------------- 1 | package class13; 2 | 3 | public class E3LocalDemo { 4 | 5 | void addElements(){ 6 | int [] arr={10,20,30}; 7 | int sum=0; 8 | for(int i=0;i=0 ; i--) { 15 | reversed=reversed+inputStr.charAt(i); 16 | } 17 | return reversed; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/class14/T4.java: -------------------------------------------------------------------------------- 1 | package class14; 2 | 3 | /* 4 | Create a method that will accept a String as a parameter and 5 | return a new String that consist only of vowels. Method should be available inside 6 | the class only where it was declared and executed by calling it is name. 7 | */ 8 | public class T4 { 9 | 10 | public static void main(String[] args) { 11 | System.out.println(getVowels("YerbolBadBoy")); 12 | } 13 | private static String getVowels(String str) { 14 | return str.replaceAll("[^aeiouAEIOU]",""); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class15/Car.java: -------------------------------------------------------------------------------- 1 | package class15; 2 | 3 | public class Car { 4 | 5 | 6 | private String make; 7 | private String model; 8 | private String color; 9 | private double price; 10 | 11 | public Car(String cMake, String cModel, String cColor, double cPrice) { 12 | make = cMake; 13 | model = cModel; 14 | color = cColor; 15 | price = cPrice; 16 | } 17 | 18 | public void printInfo(){ 19 | System.out.println(make+" "+model+" "+color+" "+price); 20 | } 21 | 22 | void setPrice(double cPrice){ 23 | price=cPrice; 24 | } 25 | 26 | double getPrice(){ 27 | return price; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/class15/CarTester.java: -------------------------------------------------------------------------------- 1 | package class15; 2 | 3 | public class CarTester { 4 | public static void main(String[] args) { 5 | 6 | Car c1=new Car("Toyota","Camry","white",35000); 7 | c1.printInfo(); 8 | c1.setPrice(30000); 9 | c1.printInfo(); 10 | System.out.println(c1.getPrice()); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/class15/ConTesterTesterDifferentPkg.java: -------------------------------------------------------------------------------- 1 | package class15; 2 | 3 | import class16.ConTester; 4 | 5 | public class ConTesterTesterDifferentPkg { 6 | public static void main(String[] args) { 7 | // new ConTester(); 8 | // new ConTester("dnfdkj"); 9 | // new ConTester(1512); 10 | new ConTester(10.52155); 11 | ConTester t=new ConTester(12.2); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/class15/Dog.java: -------------------------------------------------------------------------------- 1 | package class15; 2 | 3 | public class Dog { 4 | private String name; 5 | private String breed; 6 | private String color; 7 | private int age; 8 | 9 | public Dog(String dName, String dBreed, String dColor, int dAge) { 10 | name = dName; 11 | breed = dBreed; 12 | color = dColor; 13 | age = dAge; 14 | bark(); 15 | } 16 | 17 | public Dog(String dName, String dBreed, String dColor){ 18 | name = dName; 19 | breed = dBreed; 20 | color = dColor; 21 | } 22 | 23 | public void bark() { 24 | System.out.println("wuff wuff...."); 25 | } 26 | 27 | public void printInfo() { 28 | System.out.println(name + " " + breed + " " + color); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/class15/DogTester.java: -------------------------------------------------------------------------------- 1 | package class15; 2 | 3 | import java.util.Scanner; 4 | 5 | public class DogTester { 6 | public static void main(String[] args) { 7 | Dog d1 = new Dog("Jacky", "German", "Pink", 25); 8 | d1.printInfo(); 9 | Dog d2 = new Dog("Tom", "Russian", "Black", 23); 10 | d2.printInfo(); 11 | 12 | String name="Alina"; 13 | int size=name.length(); 14 | //Break till 12:00 15 | 16 | Scanner scanner=new Scanner(System.in); 17 | Dog d3=new Dog("Jacky", "German", "Pink"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/class15/Notes: -------------------------------------------------------------------------------- 1 | Constructors: 2 | Constructor help us build objects from classes easily. They help us give initial values to 3 | the instance fields. The name of the constructor must be same as the class name. 4 | Constructors don't have any return types. Most of the times constructors are public. 5 | Other than initializing the values we can have whatever type of code inside the constructor that 6 | we like for example calling methods writing if-else etc. 7 | 8 | Class ClassName{ 9 | String name; 10 | 11 | public ClassName(){ 12 | 13 | } 14 | 15 | public ClassName(String myName){ 16 | name=myName; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/class15/Repl.java: -------------------------------------------------------------------------------- 1 | package class15; 2 | /* 3 | 4 | 5 | Returns: 6 | 7 | ``` 8 | an integer 9 | ``` 10 | 11 | Name: 12 | 13 | ``` 14 | sumEvenToX 15 | ``` 16 | 17 | Parameters: 18 | 19 | ``` 20 | an integer called "x" 21 | ``` 22 | 23 | Purpose: 24 | 25 | ``` 26 | calculate the sum of the EVEN integers from 1 to x (including x) 27 | ``` 28 | 29 | Examples: 30 | 31 | ``` 32 | sumEvenToX(5) ==> 6 33 | sumEvenToX(8) ==> 20 34 | */ 35 | public class Repl { 36 | 37 | public static void main(String[] args) { 38 | // 2 4 6 8 10 39 | System.out.println(sumEvenToX(10)); 40 | } 41 | static int sumEvenToX(int x){ 42 | int sum=0; 43 | for (int i = 2; i <=x ; i=i+2) { 44 | sum=sum+i; 45 | } 46 | return sum; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/class15/SeleniumDemo.java: -------------------------------------------------------------------------------- 1 | package class15; 2 | 3 | import org.openqa.selenium.chrome.ChromeDriver; 4 | 5 | public class SeleniumDemo { 6 | 7 | public static void main(String[] args) throws InterruptedException { 8 | 9 | ChromeDriver chrome=new ChromeDriver(); 10 | chrome.navigate().to("https://facebook.com"); 11 | System.out.println(chrome.getTitle()); 12 | Thread.sleep(3000); 13 | chrome.navigate().to("https://amazon.com"); 14 | Thread.sleep(3000); 15 | chrome.navigate().refresh(); 16 | Thread.sleep(3000); 17 | chrome.navigate().back(); 18 | Thread.sleep(3000); 19 | chrome.close(); 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/class15/Student.java: -------------------------------------------------------------------------------- 1 | package class15; 2 | 3 | public class Student { 4 | 5 | private String name; 6 | private double marks1; 7 | private double marks2; 8 | private double marks3; 9 | 10 | public Student(String sName, double sMarks1, double sMarks2, double sMarks3) { 11 | name = sName; 12 | marks1 = sMarks1; 13 | marks2 = sMarks2; 14 | marks3 = sMarks3; 15 | } 16 | 17 | public void printAvg(){ 18 | 19 | double avg=(marks1+marks2+marks3)/3; 20 | System.out.println(name+ " Got "+avg); 21 | 22 | } 23 | public void printName(){ 24 | System.out.println(name); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/class15/StudentTester.java: -------------------------------------------------------------------------------- 1 | package class15; 2 | 3 | public class StudentTester { 4 | public static void main(String[] args) { 5 | 6 | Student s1 = new Student("Jamel", 84, 95, 92); 7 | s1.printAvg(); 8 | s1.printName(); 9 | Student s2 = new Student("john", 74, 95, 98); 10 | s2.printAvg(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/class15/T1.java: -------------------------------------------------------------------------------- 1 | package class15; 2 | 3 | public class T1 { 4 | 5 | private String address; 6 | 7 | public T1(String userAddress) { 8 | address = userAddress; 9 | System.out.println("Executed constructor with parameter " + userAddress); 10 | 11 | } 12 | 13 | // Break till 1:52 14 | public T1() { 15 | System.out.println("Executed constructor with No parameters"); 16 | } 17 | 18 | public static void main(String[] args) { 19 | new T1(); 20 | new T1("Canada"); 21 | 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /src/main/java/class15/Test.java: -------------------------------------------------------------------------------- 1 | package class15; 2 | 3 | public class Test { 4 | 5 | 6 | public static void main(String[] args) { 7 | // Test t=new Test(25,"Asha"); 8 | Test t=new Test(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/class16/CatTester.java: -------------------------------------------------------------------------------- 1 | package class16; 2 | 3 | public class CatTester { 4 | public static void main(String[] args) { 5 | Cat c1=new Cat("Bubbles","Bul'ka","black",5); 6 | c1.printInfo(); 7 | 8 | Cat c2=new Cat(); 9 | c2.printInfo(); 10 | 11 | Cat c3=new Cat("Bubbles","Bul'ka","black",5,'M'); 12 | c3.printInfo(); 13 | 14 | Cat c4=new Cat("Bubbles","Bul'ka","black",5,'M',25); 15 | c4.printInfo(); 16 | } 17 | } -------------------------------------------------------------------------------- /src/main/java/class16/ConTesterTester.java: -------------------------------------------------------------------------------- 1 | package class16; 2 | 3 | public class ConTesterTester { 4 | public static void main(String[] args) { 5 | // new ConTester(); 6 | new ConTester("dnfdkj"); 7 | new ConTester(1512); 8 | new ConTester(10.52155); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/class16/Notes: -------------------------------------------------------------------------------- 1 | Notes = 2 | 3 | Constructors: 4 | Constructors hlp us create the objects from the classes in a more secure and neat way. 5 | We can also put any piece of code that we want to execute when the object of a class is created. 6 | 7 | Why we should use Constructors? 8 | 9 | They help us write more secure classes 10 | Cleaner code 11 | More control over the values we can assign to the instance fields 12 | 13 | Syntax: 14 | 15 | No return type not even void 16 | Same name as class 17 | Usually public access modifier 18 | Parameters 19 | Body of the constructor 20 | 21 | Rules: 22 | 23 | 24 | 25 | 26 | Create Cat class define 6 fields create multiple constructors to give 27 | flexibility to the end user. PrintInfo method as well to print all the details of 28 | a cat. -------------------------------------------------------------------------------- /src/main/java/class16/PersonTester.java: -------------------------------------------------------------------------------- 1 | package class16; 2 | 3 | public class PersonTester { 4 | public static void main(String[] args) { 5 | Person p1 = new Person("Fahim", 6 | 26, 85, 'M'); 7 | p1.printInfo(); 8 | 9 | Person p2 = new Person("Mikhail", 10 | 26, 85, 'M',120000,"Bold"); 11 | p2.printInfo(); 12 | 13 | Person p3=new Person(); 14 | 15 | //Break till 11:52 16 | 17 | } 18 | } -------------------------------------------------------------------------------- /src/main/java/class16/Student.java: -------------------------------------------------------------------------------- 1 | package class16; 2 | 3 | public class Student { 4 | 5 | private String name; 6 | private String address; 7 | 8 | public Student (String name, String address){ 9 | this.name= name; 10 | this.address= address; 11 | } 12 | public void displayInfo(){ 13 | System.out.println(name+" "+ address); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class16/StudentTester.java: -------------------------------------------------------------------------------- 1 | package class16; 2 | 3 | public class StudentTester { 4 | public static void main(String[] args) { 5 | Student s1 = new Student("Uzair", "UK"); 6 | s1.displayInfo(); 7 | } 8 | } -------------------------------------------------------------------------------- /src/main/java/class17/A.java: -------------------------------------------------------------------------------- 1 | package class17; 2 | 3 | public class A { 4 | String name; 5 | 6 | void printName(){ 7 | System.out.println(name); 8 | } 9 | } 10 | 11 | class B extends A{ 12 | String color; 13 | void printColor(){ 14 | System.out.println(color); 15 | } 16 | } 17 | 18 | class C extends B{ 19 | 20 | void printNameColor(){ 21 | System.out.println(name+" "+color); 22 | } 23 | } 24 | class D extends B{ 25 | 26 | } -------------------------------------------------------------------------------- /src/main/java/class17/Animal.java: -------------------------------------------------------------------------------- 1 | package class17; 2 | 3 | import class17.Cat; 4 | 5 | public class Animal { 6 | String name; 7 | String breed; 8 | String color; 9 | int age; 10 | 11 | void printInfo(){ 12 | System.out.println(name+" "+breed+" "+color+" "+age); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/class17/AnimalTester.java: -------------------------------------------------------------------------------- 1 | package class17; 2 | 3 | public class AnimalTester { 4 | public static void main(String[] args) { 5 | 6 | Cat c=new Cat(); 7 | c.name="Tom"; 8 | c.breed="Russian"; 9 | c.color="White"; 10 | c.age=8; 11 | c.attitude=true; 12 | c.printInfo(); 13 | Dog d=new Dog(); 14 | d.bark(); 15 | d.name="Jacky"; 16 | d.breed="German"; 17 | d.printInfo(); 18 | Animal a=new Animal(); 19 | a.name="Jim"; 20 | a.color="Black"; 21 | a.printInfo(); 22 | 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/class17/Cat.java: -------------------------------------------------------------------------------- 1 | package class17; 2 | 3 | public class Cat extends Animal{ 4 | 5 | boolean attitude; 6 | 7 | void printName(){ 8 | System.out.println(name); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/class17/CatDog.java: -------------------------------------------------------------------------------- 1 | package class17; 2 | 3 | /*public class CatDog extends Dog,Cat{ 4 | }*/ 5 | // Multiple inheritance not allowed in java meaning a class can't inherent from 6 | // multiple classes at the same time. 7 | -------------------------------------------------------------------------------- /src/main/java/class17/Dee.java: -------------------------------------------------------------------------------- 1 | package class17; 2 | 3 | public class Dee { 4 | static String name="Jamel"; 5 | static void printF(){ 6 | System.out.println("f"); 7 | } 8 | } 9 | 10 | class Eff extends Dee{ 11 | public static void main(String[] args) { 12 | printF(); 13 | System.out.println(name); 14 | } 15 | } -------------------------------------------------------------------------------- /src/main/java/class17/Dog.java: -------------------------------------------------------------------------------- 1 | package class17; 2 | 3 | public class Dog extends Animal { 4 | void bark(){ 5 | System.out.println("Wuff Wuff"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/class17/HondaBike.java: -------------------------------------------------------------------------------- 1 | package class17; 2 | 3 | import class18.Bike; 4 | 5 | 6 | public class HondaBike extends Bike { 7 | 8 | void printModel(){ 9 | System.out.println(make); 10 | } 11 | } 12 | 13 | class Tester{ 14 | public static void main(String[] args) { 15 | 16 | Bike b=new Bike(); 17 | //System.out.println(b.make); 18 | 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/java/class17/MultiLevelTester.java: -------------------------------------------------------------------------------- 1 | package class17; 2 | 3 | public class MultiLevelTester { 4 | public static void main(String[] args) { 5 | C c=new C(); 6 | 7 | c.printName(); 8 | c.printColor(); 9 | c.printNameColor(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/class17/X.java: -------------------------------------------------------------------------------- 1 | package class17; 2 | 3 | public class X { 4 | String name; 5 | void printName(){ 6 | System.out.println(name); 7 | } 8 | } 9 | 10 | class Y extends X{ 11 | String lastname; 12 | void printLastName(){ 13 | System.out.println(lastname); 14 | 15 | } 16 | 17 | } 18 | class Z extends Y { 19 | int age; 20 | 21 | void printAge(){ 22 | System.out.println(age); 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /src/main/java/class18/Bike.java: -------------------------------------------------------------------------------- 1 | package class18; 2 | 3 | public class Bike { 4 | protected String make; 5 | String model; 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/class18/CarTester.java: -------------------------------------------------------------------------------- 1 | package class18; 2 | 3 | public class CarTester { 4 | public static void main(String[] args) { 5 | 6 | BMW i8=new BMW("BMW","I8",80000,"Black"); 7 | 8 | i8.printInfo(); 9 | 10 | Audi a=new Audi("Audi","Etron",60000,"White"); 11 | a.printInfo(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/class18/Furniture.java: -------------------------------------------------------------------------------- 1 | package class18; 2 | 3 | class GrandPa{ 4 | String color="White"; 5 | } 6 | public class Furniture extends GrandPa{ 7 | String color="Black"; 8 | } 9 | 10 | class Chair extends Furniture{ 11 | String color="Brown"; 12 | void printColor(){ 13 | String color="Blue"; 14 | System.out.println(color); 15 | System.out.println(this.color); 16 | System.out.println(super.color); 17 | 18 | } 19 | } 20 | class FurnitureTester{ 21 | public static void main(String[] args) { 22 | Chair chair=new Chair(); 23 | chair.printColor(); 24 | } 25 | } -------------------------------------------------------------------------------- /src/main/java/class18/GrandParent.java: -------------------------------------------------------------------------------- 1 | package class18; 2 | 3 | public class GrandParent { 4 | public GrandParent(){ 5 | System.out.println("Granpa"); 6 | } 7 | } 8 | class Parent extends GrandParent{ 9 | public Parent(){ 10 | System.out.println("Parent"); 11 | } 12 | } 13 | 14 | class Children extends Parent{ 15 | Children(){ 16 | System.out.println("Children"); 17 | } 18 | } 19 | class Tester{ 20 | public static void main(String[] args) { 21 | 22 | Children c=new Children(); 23 | } 24 | } -------------------------------------------------------------------------------- /src/main/java/class18/Shape.java: -------------------------------------------------------------------------------- 1 | package class18; 2 | 3 | public class Shape { 4 | float radius=3; 5 | 6 | 7 | } 8 | class circle extends Shape{ 9 | 10 | void area(){ 11 | double area=radius*radius*Math.PI; 12 | System.out.println("Area of circle : " + area); 13 | } 14 | } 15 | class test{ 16 | public static void main(String[] args) { 17 | circle obj=new circle(); 18 | obj.area(); 19 | 20 | } 21 | } -------------------------------------------------------------------------------- /src/main/java/class19/Ali.java: -------------------------------------------------------------------------------- 1 | package class19; 2 | 3 | 4 | class Parent{ 5 | 6 | void marry(){ 7 | System.out.println("We want you to marry Salma"); 8 | } 9 | } 10 | public class Ali extends Parent{ 11 | void marry(){ 12 | System.out.println("I want to marry Tylor Swift"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/class19/AnimalTester.java: -------------------------------------------------------------------------------- 1 | package class19; 2 | 3 | public class AnimalTester { 4 | public static void main(String[] args) { 5 | Dog d=new Dog("Jacki","Black",12,20.5); 6 | d.printInfo(); 7 | //Break till 1:52 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/class19/CalculatorTester.java: -------------------------------------------------------------------------------- 1 | package class19; 2 | 3 | public class CalculatorTester { 4 | public static void main(String[] args) { 5 | 6 | Calculator c=new Calculator(); 7 | c.add(20,20,20); 8 | c.add(10.5,10.5); 9 | c.add(10.5,10); 10 | 11 | System.out.println(10); 12 | System.out.println(5.5); 13 | System.out.println("skjksj"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/class19/CreditCard.java: -------------------------------------------------------------------------------- 1 | package class19; 2 | 3 | import io.opentelemetry.exporter.logging.SystemOutLogRecordExporter; 4 | 5 | /* 6 | Create a class CreditCard Create an instance method that will calculate 7 | interest based on the given balance. 8 | Create 2 subclasses: Visa and AX. In AX class override method calculate interest. 9 | Call the method by creating an object of each of the three classes 10 | 11 | */ 12 | public class CreditCard { 13 | 14 | public void calInterest(double balance){ 15 | System.out.println(balance*0.05); 16 | } 17 | } 18 | 19 | class Visa extends CreditCard{ 20 | 21 | } 22 | 23 | class AX extends CreditCard{ 24 | 25 | @Override 26 | public void calInterest(double balance) { 27 | System.out.println(balance*0.07); 28 | } 29 | } -------------------------------------------------------------------------------- /src/main/java/class19/CreditCardTester.java: -------------------------------------------------------------------------------- 1 | package class19; 2 | 3 | public class CreditCardTester { 4 | public static void main(String[] args) { 5 | 6 | CreditCard c=new CreditCard(); 7 | c.calInterest(100); 8 | Visa v=new Visa(); 9 | v.calInterest(100); 10 | AX ax=new AX(); 11 | ax.calInterest(100); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/class19/Programming.java: -------------------------------------------------------------------------------- 1 | package class19; 2 | /* 3 | Create a class named 'Programming'. While creating an object of the class, 4 | if nothing is passed to it, then the message "I love programming languages" 5 | should be printed. If some String is passed to it, then in place of "programming 6 | languages" the value variable should be printed. Example, if we pass "Java", 7 | then "I love Java" should be printed. 8 | */ 9 | public class Programming { 10 | 11 | public Programming(){ 12 | System.out.println("I love programming languages"); 13 | } 14 | 15 | public Programming(String word){ 16 | System.out.println("I love "+word); 17 | } 18 | 19 | 20 | public static void main(String[] args) { 21 | Programming p= new Programming("Java"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/class19/T1.java: -------------------------------------------------------------------------------- 1 | package class19; 2 | 3 | public class T1 { 4 | 5 | public int min(int num1,int num2){ 6 | 7 | // return num1 arr=new ArrayList(); 10 | arr.add("Ace"); 11 | arr.add("Habib"); 12 | arr.add("Gulcan"); 13 | System.out.println(arr.get(2)); 14 | System.out.println(arr.isEmpty()); 15 | System.out.println(arr.contains("sdsd")); 16 | System.out.println(arr.indexOf("Habib")); 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/class23/RegistrationTester.java: -------------------------------------------------------------------------------- 1 | package class23; 2 | 3 | public class RegistrationTester { 4 | 5 | 6 | public static void main(String[] args) { 7 | Registration r = new Registration("giulia@yahoo.com", "User123", "Pass123"); 8 | 9 | 10 | System.out.println("Email: " + r.getEmail()); 11 | System.out.println("Username: " + r.getUsername()); 12 | System.out.println("Password: " + r.getPassword()); 13 | } 14 | } -------------------------------------------------------------------------------- /src/main/java/class24/E1ArrayList.java: -------------------------------------------------------------------------------- 1 | package class24; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class E1ArrayList { 6 | public static void main(String[] args) { 7 | 8 | ArrayList names=new ArrayList<>(); 9 | names.add("Deepali"); 10 | names.add("Ahmed"); 11 | names.add("Mike"); 12 | names.add("John"); 13 | names.add("Ali"); 14 | // names.remove(0); 15 | names.remove("Deepali"); 16 | System.out.println(names); 17 | names.add(2,"Ehab"); 18 | System.out.println(names); 19 | names.set(1,"Jamel"); 20 | System.out.println(names); 21 | 22 | 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/class24/E3ArrayList.java: -------------------------------------------------------------------------------- 1 | package class24; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class E3ArrayList { 6 | public static void main(String[] args) { 7 | 8 | ArrayList numbers=new ArrayList<>(); 9 | 10 | Integer num1=new Integer(10); 11 | Integer num2=new Integer(20); 12 | System.out.println(num1+num2); 13 | 14 | String s="Jamel"; 15 | String d=new String("Jamel"); 16 | 17 | Integer num3=45; 18 | Integer num4=50; 19 | System.out.println(num3+num4); 20 | // Break till 11:58 21 | 22 | 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/class24/E4ArrayList.java: -------------------------------------------------------------------------------- 1 | package class24; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class E4ArrayList { 6 | public static void main(String[] args) { 7 | 8 | ArrayList numbers=new ArrayList<>(); 9 | numbers.add(10); 10 | numbers.add(20); 11 | numbers.add(25); 12 | numbers.add(100); 13 | numbers.add(5); 14 | System.out.println(numbers); 15 | int sum=0; 16 | for(int n:numbers){ 17 | if(n>20){ 18 | sum+=n; // sum=sum+n 19 | } 20 | } 21 | System.out.println(sum); 22 | 23 | 24 | 25 | 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/class24/E5BoxingUnBoxing.java: -------------------------------------------------------------------------------- 1 | package class24; 2 | 3 | public class E5BoxingUnBoxing { 4 | public static void main(String[] args) { 5 | 6 | int a=10; 7 | Integer number=new Integer(a); 8 | int d=number.intValue(); // converting from a class to a primitive 9 | System.out.println(d); 10 | 11 | Integer c=10; // AutoBoxing 12 | int f=c; // AutoUnboxing 13 | System.out.println(f); 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class24/E6.java: -------------------------------------------------------------------------------- 1 | package class24; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class E6 { 6 | public static void main(String[] args) { 7 | ArrayList words=new ArrayList<>(); 8 | words.add("milk"); 9 | words.add("banana"); 10 | words.add("coffee"); 11 | words.add("table"); 12 | words.add("TV"); 13 | /* for (String x:words){ 14 | System.out.println(x); 15 | }*/ 16 | words.forEach(x-> System.out.println(x)); 17 | /* for (int i = 0; ix.contains("e")); 25 | 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/class24/T4.java: -------------------------------------------------------------------------------- 1 | package class24; 2 | 3 | import java.util.ArrayList; 4 | 5 | /* 6 | Create an arrayList of even numbers from 1 to 500. 7 | Remove any number that is divisible by 5 from that arrayList. 8 | */ 9 | public class T4 { 10 | public static void main(String[] args) { 11 | 12 | ArrayList numbers=new ArrayList<>(); 13 | 14 | for (int i = 2; i <= 500; i+=2) { 15 | numbers.add(i); 16 | } 17 | System.out.println(numbers); 18 | /*for (int i = 0; i < numbers.size(); i++) { 19 | if(numbers.get(i)%5==0){ 20 | numbers.remove(i); 21 | } 22 | }*/ 23 | numbers.removeIf(x->x%5==0); 24 | System.out.println(numbers); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/class24/T5.java: -------------------------------------------------------------------------------- 1 | package class24; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class T5 { 6 | public static void main(String[] args) { 7 | /* 8 | create an arrayList of fruit then remove all the fruit which contains 9 | the letter a or ends with the letter e 10 | */ 11 | ArrayList fruit= new ArrayList<>(); 12 | fruit.add("Mango"); 13 | fruit.add("Kiwi"); 14 | fruit.add("Banana"); 15 | fruit.add("Orange"); 16 | fruit.add("Apple"); 17 | fruit.add("Watermelon"); 18 | fruit.add("Peach"); 19 | fruit.removeIf(d->d.contains("a")||d.endsWith("e")); 20 | System.out.println(fruit); 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/class25/E10.java: -------------------------------------------------------------------------------- 1 | package class25; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashSet; 5 | import java.util.LinkedHashSet; 6 | 7 | public class E10 { 8 | public static void main(String[] args) { 9 | 10 | ArrayList numbers=new ArrayList<>(); 11 | numbers.add(10); 12 | numbers.add(20); 13 | numbers.add(30); 14 | numbers.add(40); 15 | numbers.add(10); 16 | System.out.println(numbers); 17 | LinkedHashSet set=new LinkedHashSet<>(numbers); 18 | System.out.println(set); 19 | numbers.clear(); 20 | System.out.println(numbers); 21 | numbers.addAll(set); 22 | System.out.println(numbers); 23 | 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/class25/E1ArrayList.java: -------------------------------------------------------------------------------- 1 | package class25; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class E1ArrayList { 6 | public static void main(String[] args) { 7 | 8 | int [] arr=new int[5]; 9 | ArrayList numbers=new ArrayList<>(); 10 | numbers.add(20); 11 | numbers.add(40); 12 | numbers.add(30); 13 | numbers.add(50); 14 | numbers.add(12); 15 | System.out.println(numbers); 16 | numbers.remove(1); 17 | System.out.println(numbers); 18 | numbers.removeIf(x->x>12); 19 | System.out.println(numbers); 20 | 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/class25/E1Sets.java: -------------------------------------------------------------------------------- 1 | package class25; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashSet; 5 | 6 | public class E1Sets { 7 | public static void main(String[] args) { 8 | ArrayList numbers=new ArrayList<>(); 9 | // We can store duplicates in an ArrayList or LinkedList 10 | numbers.add(10); 11 | numbers.add(20); 12 | numbers.add(10); 13 | System.out.println(numbers); 14 | 15 | HashSet uniqNumbers=new HashSet<>(); 16 | uniqNumbers.add(10); 17 | uniqNumbers.add(20); 18 | // uniqNumbers.add(10); 19 | // uniqNumbers.add(10); 20 | System.out.println(uniqNumbers); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/class25/E2ArrayList.java: -------------------------------------------------------------------------------- 1 | package class25; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class E2ArrayList { 6 | public static void main(String[] args) { 7 | 8 | ArrayList numbers=new ArrayList<>(); 9 | numbers.add(20); 10 | numbers.add(40); 11 | numbers.add(30); 12 | numbers.add(50); 13 | numbers.add(12); 14 | numbers.forEach(x-> System.out.println(x)); 15 | 16 | 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/class25/E3ArrayList.java: -------------------------------------------------------------------------------- 1 | package class25; 2 | 3 | import java.util.ArrayList; 4 | import java.util.LinkedList; 5 | import java.util.List; 6 | 7 | public class E3ArrayList { 8 | public static void main(String[] args) { 9 | List numbers=new LinkedList<>(); 10 | numbers.add(10); 11 | numbers.add(15); 12 | numbers.add(20); 13 | numbers.add(30); 14 | numbers.add(50); 15 | System.out.println(numbers); 16 | numbers.remove(2); 17 | System.out.println(numbers); 18 | numbers.removeIf(x->x>15); 19 | System.out.println(numbers); 20 | 21 | 22 | 23 | 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/class25/E4ArrayListVsLinkedList.java: -------------------------------------------------------------------------------- 1 | package class25; 2 | 3 | import java.util.ArrayList; 4 | import java.util.LinkedList; 5 | 6 | public class E4ArrayListVsLinkedList { 7 | public static void main(String[] args) { 8 | 9 | long startingTime=System.currentTimeMillis(); 10 | 11 | LinkedList numbers=new LinkedList<>(); 12 | for (int i = 0; i < 100000; i++) { 13 | numbers.add(0,i); 14 | } 15 | 16 | long endTime=System.currentTimeMillis(); 17 | long timeTook=(endTime-startingTime); 18 | System.out.println(timeTook); 19 | 20 | 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/class25/E5ArrayListVsLinkedList.java: -------------------------------------------------------------------------------- 1 | package class25; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.LinkedList; 6 | 7 | public class E5ArrayListVsLinkedList { 8 | public static void main(String[] args) { 9 | 10 | long startingTime=System.currentTimeMillis(); 11 | // 45 1340 12 | ArrayList numbers=new ArrayList<>(); 13 | for (int i = 0; i < 1000000; i++) { 14 | numbers.add(i); 15 | } 16 | for (int i = 0; i < 1000; i++) { 17 | System.out.println(numbers.get(100000)); 18 | } 19 | 20 | long endTime=System.currentTimeMillis(); 21 | long timeTook=(endTime-startingTime); 22 | System.out.println(timeTook); 23 | 24 | 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/class25/E7Sets.java: -------------------------------------------------------------------------------- 1 | package class25; 2 | 3 | import java.util.HashSet; 4 | 5 | public class E7Sets { 6 | //Sets 7 | public static void main(String[] args) { 8 | 9 | HashSet fruit=new HashSet<>(); 10 | fruit.add("Mango"); 11 | fruit.add("Kiwi"); 12 | fruit.add("Orange"); 13 | fruit.add("Banana"); 14 | fruit.add("Banana"); 15 | System.out.println(fruit); 16 | //1)No Duplicates 2) No Insertion Order 17 | fruit.forEach(x-> System.out.println(x)); 18 | System.out.println("**************"); 19 | for (String f:fruit){ 20 | System.out.println(f); 21 | } 22 | 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/class25/E8Sets.java: -------------------------------------------------------------------------------- 1 | package class25; 2 | 3 | import java.util.LinkedHashSet; 4 | 5 | public class E8Sets { 6 | public static void main(String[] args) { 7 | 8 | LinkedHashSet uniqueNumbers=new LinkedHashSet<>(); 9 | uniqueNumbers.add(10); 10 | uniqueNumbers.add(20); 11 | uniqueNumbers.add(10); 12 | uniqueNumbers.add(30); 13 | System.out.println(uniqueNumbers); 14 | 15 | 16 | 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/class25/E9Set.java: -------------------------------------------------------------------------------- 1 | package class25; 2 | 3 | import java.util.TreeSet; 4 | 5 | public class E9Set { 6 | public static void main(String[] args) { 7 | 8 | TreeSet numbers=new TreeSet<>(); 9 | numbers.add(10); 10 | numbers.add(20); 11 | numbers.add(30); 12 | numbers.add(5); 13 | numbers.add(2); 14 | numbers.add(10); 15 | System.out.println(numbers); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/class25/T2ArrayList.java: -------------------------------------------------------------------------------- 1 | package class25; 2 | 3 | import java.util.ArrayList; 4 | import java.util.LinkedHashSet; 5 | import java.util.List; 6 | 7 | public class T2ArrayList { 8 | public static void main(String[] args) { 9 | List aList = new ArrayList<>(); 10 | aList.add("John"); 11 | aList.add("Jane"); 12 | aList.add("James"); 13 | aList.add("Jasmine"); 14 | aList.add("Jane"); 15 | aList.add("James"); 16 | System.out.println(aList); 17 | LinkedHashSet set = new LinkedHashSet<>(aList); 18 | aList.clear(); 19 | aList.addAll(set); 20 | System.out.println(aList); 21 | 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/class25/T4Sets.java: -------------------------------------------------------------------------------- 1 | package class25; 2 | 3 | import java.util.LinkedHashSet; 4 | 5 | public class T4Sets { 6 | public static void main(String[] args) { 7 | 8 | LinkedHashSet cities= new LinkedHashSet<>(); 9 | cities.add("Toronto"); 10 | cities.add("New York"); 11 | cities.add("Vancouver"); 12 | cities.add("Amsterdam"); 13 | cities.add("Calgary"); 14 | cities.add("California"); 15 | cities.add("Berlin"); 16 | cities.add("Aurora"); 17 | cities.add("Ankara"); 18 | cities.add("Alexandria"); 19 | System.out.println(cities); 20 | 21 | 22 | cities.removeIf(x->x.toLowerCase().startsWith("a")); 23 | System.out.println(cities); 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/class26/E11Maps.java: -------------------------------------------------------------------------------- 1 | package class26; 2 | 3 | 4 | import java.util.TreeMap; 5 | 6 | public class E11Maps { 7 | public static void main(String[] args) { 8 | TreeMap makeup = new TreeMap<>(); 9 | makeup.put("Lipsticks", 22.0); 10 | makeup.put("BlushOn", 40.0); 11 | makeup.put("Base", 50.5); 12 | makeup.put("Foundation", 90.5); 13 | makeup.put("EyeLiner", 25.5); 14 | makeup.put("Concealer", 35.5); 15 | makeup.put("EyeLiner", 25.5); 16 | //makeup.entrySet().removeIf(x->x.getKey().contains("a")); 17 | //makeup.entrySet().removeIf(x->x.getValue()>30); 18 | makeup.entrySet().removeIf(x->x.getKey().contains("a")&&x.getValue()>30); 19 | System.out.println(makeup); 20 | 21 | 22 | 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/class26/E1Maps.java: -------------------------------------------------------------------------------- 1 | package class26; 2 | 3 | import java.util.Collection; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | public class E1Maps { 8 | public static void main(String[] args) { 9 | 10 | HashMap fruit=new HashMap<>(); 11 | fruit.put("Apple",8.0); 12 | fruit.put("Banana",3.0); 13 | fruit.put("Orange",5.2); 14 | fruit.put("Kiwi",4.0); 15 | fruit.put("Apple",4.0); 16 | System.out.println(fruit); 17 | System.out.println(fruit.size()); 18 | System.out.println(fruit.containsKey("Apple")); 19 | System.out.println(fruit.containsValue(4.0)); 20 | System.out.println(fruit.containsValue(44)); 21 | System.out.println(fruit.isEmpty()); 22 | 23 | 24 | 25 | 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/class26/E2Maps.java: -------------------------------------------------------------------------------- 1 | package class26; 2 | 3 | import class17.Dog; 4 | 5 | import java.util.HashMap; 6 | import java.util.LinkedHashMap; 7 | 8 | public class E2Maps { 9 | public static void main(String[] args) { 10 | 11 | LinkedHashMap students= new LinkedHashMap<>(); 12 | students.put(10,"Adam"); 13 | students.put(20,"Ehab"); 14 | students.put(300,"Marta"); 15 | students.put(45,"Ahmed"); 16 | System.out.println(students); 17 | students.remove(300); 18 | System.out.println(students); 19 | students.replace(20,"Jamel"); 20 | System.out.println(students); 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/class26/E5Maps.java: -------------------------------------------------------------------------------- 1 | package class26; 2 | 3 | import java.util.Map; 4 | import java.util.Set; 5 | import java.util.TreeMap; 6 | 7 | public class E5Maps { 8 | public static void main(String[] args) { 9 | TreeMap makeup=new TreeMap<>(); 10 | makeup.put("Lipsticks",22.0); 11 | makeup.put("BlushOn",40.0); 12 | makeup.put("Base",50.5); 13 | makeup.put("Foundation",90.5); 14 | makeup.put("EyeLiner",25.5); 15 | makeup.put("Concealer",35.5); 16 | makeup.put("EyeLiner",25.5); 17 | 18 | Set> entries= makeup.entrySet(); 19 | for (Map.Entry e:entries){ 20 | System.out.println(e.getKey()+" "+e.getValue()); 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/class26/E7Maps.java: -------------------------------------------------------------------------------- 1 | package class26; 2 | 3 | 4 | import java.util.ArrayList; 5 | 6 | public class E7Maps { 7 | public static void main(String[] args) { 8 | 9 | 10 | ArrayList names=new ArrayList<>(); 11 | //new ArrayList<>(); => Creating the object of the ArrayList Class 12 | names.add("Avis"); 13 | names.add("Adam"); 14 | names.add("John"); 15 | names.add("James"); 16 | 17 | String name="James"; 18 | Integer a=10; 19 | 20 | ArrayList numbers=new ArrayList<>(); 21 | numbers.add(10); 22 | numbers.add(20); 23 | 24 | ArrayList> arrayLists=new ArrayList<>(); 25 | arrayLists.add(names); 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/class26/E8Maps.java: -------------------------------------------------------------------------------- 1 | package class26; 2 | 3 | 4 | import java.util.ArrayList; 5 | import java.util.HashMap; 6 | import java.util.LinkedList; 7 | import java.util.Map; 8 | 9 | public class E8Maps { 10 | public static void main(String[] args) { 11 | 12 | 13 | LinkedList> test=new LinkedList<>(); 14 | 15 | ArrayList names=new ArrayList<>(); 16 | names.add("Jamel"); 17 | // test.add(20) // error 18 | // test.add(names) 19 | LinkedList numbers=new LinkedList<>(); 20 | // test.add(numbers) 21 | Map map=new HashMap<>(); 22 | // test.add(map) 23 | ArrayList n=new ArrayList<>(); 24 | test.add(n); 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/class28/ExcelReaderTester.java: -------------------------------------------------------------------------------- 1 | package class28; 2 | 3 | import utils.ExcelReader; 4 | 5 | import java.io.IOException; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | public class ExcelReaderTester { 10 | public static void main(String[] args) throws IOException { 11 | 12 | List> data= ExcelReader.readExcelData("C:\\Users\\Syntax\\IdeaProjects\\JavaSdetBatch17\\Files\\Sales.xlsx"); 13 | System.out.println(data); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/class28/Notes: -------------------------------------------------------------------------------- 1 | Create an excel file store some data inside it and read that 2 | data using the methods that we have just created. -------------------------------------------------------------------------------- /src/main/java/class29/E10Exceptions.java: -------------------------------------------------------------------------------- 1 | package class29; 2 | 3 | import java.io.FileInputStream; 4 | import java.io.FileNotFoundException; 5 | import java.io.IOException; 6 | 7 | public class E10Exceptions { 8 | public static void main(String[] args) { 9 | 10 | try( FileInputStream fileInputStream = new FileInputStream("C:\\Users\\Syntax\\Desktop\\Batch 17\\salaries.xlsx")) { 11 | 12 | 13 | } catch (Exception f) { 14 | System.out.println("Please check the file path"); 15 | } 16 | 17 | } 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/class29/E11Exceptions.java: -------------------------------------------------------------------------------- 1 | package class29; 2 | 3 | import java.io.FileInputStream; 4 | import java.io.FileNotFoundException; 5 | 6 | public class E11Exceptions { 7 | public static void main(String[] args) { 8 | 9 | 10 | String path=null; 11 | try { 12 | FileInputStream fis=new FileInputStream(path); 13 | } catch (FileNotFoundException e) { 14 | System.out.println("heheh"); 15 | } 16 | 17 | } 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/class29/E1Exceptions.java: -------------------------------------------------------------------------------- 1 | package class29; 2 | 3 | public class E1Exceptions { 4 | public static void main(String[] args) { 5 | 6 | // age int=10; 7 | int age=10; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/class29/E2Exceptions.java: -------------------------------------------------------------------------------- 1 | package class29; 2 | 3 | public class E2Exceptions { 4 | public static void main(String[] args) { 5 | 6 | System.out.println(12); 7 | 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/class29/E3Exceptions.java: -------------------------------------------------------------------------------- 1 | package class29; 2 | 3 | public class E3Exceptions { 4 | public static void main(String[] args) { 5 | System.out.println("a"); 6 | System.out.println("a"); 7 | System.out.println("a"); 8 | System.out.println("a"); 9 | System.out.println(10/0); 10 | System.out.println("b"); 11 | System.out.println("b"); 12 | System.out.println("b"); 13 | 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/class29/E4Exceptions.java: -------------------------------------------------------------------------------- 1 | package class29; 2 | 3 | import class10.Dog; 4 | import class23.BankAccount; 5 | 6 | 7 | public class E4Exceptions { 8 | public static void main(String[] args) { 9 | 10 | // int[] arr= new int[-5]; 11 | // System.out.println(10/0); 12 | // store nothing in bankAccount variable 13 | /* BankAccount bankAccount=null; 14 | bankAccount.getBankAccountNumber();*/ 15 | 16 | String s="Java"; 17 | System.out.println( s.charAt(5)); 18 | //Break till 11:52 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/class29/E7Exceptions.java: -------------------------------------------------------------------------------- 1 | package class29; 2 | 3 | 4 | import javax.swing.table.JTableHeader; 5 | import java.io.FileInputStream; 6 | import java.io.FileNotFoundException; 7 | 8 | public class E7Exceptions { 9 | public static void main(String[] args) throws FileNotFoundException { 10 | 11 | System.out.println("1"); 12 | 13 | int num1 = 10; 14 | int numb2 = 0; 15 | if (numb2 != 0) { 16 | System.out.println(num1 / numb2); 17 | } 18 | 19 | System.out.println(10 / 0); 20 | int[] arr = new int[-5]; 21 | 22 | 23 | FileInputStream f = new FileInputStream("C//sdsds"); 24 | // Thread.sleep(2000); 25 | // Break till 1:52 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/class29/E8Exceptions.java: -------------------------------------------------------------------------------- 1 | package class29; 2 | 3 | import java.io.FileInputStream; 4 | import java.io.FileNotFoundException; 5 | import java.io.IOException; 6 | 7 | public class E8Exceptions { 8 | public static void main(String[] args) { 9 | E8Exceptions e=new E8Exceptions(); 10 | e.readFile(); 11 | } 12 | 13 | 14 | 15 | void readFile() { 16 | read(); 17 | } 18 | 19 | 20 | void read() { 21 | try { 22 | FileInputStream fis=new FileInputStream("C://sdsds"); 23 | }catch (FileNotFoundException f){ 24 | 25 | } 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/class3/E10ElseIf.java: -------------------------------------------------------------------------------- 1 | package class3; 2 | 3 | public class E10ElseIf { 4 | public static void main(String[] args) { 5 | 6 | String fruit="Kiwi"; 7 | 8 | if(fruit.equals("Mango")){ //fruit=="Mango" 9 | System.out.println("Price is $5"); 10 | }else if(fruit.equals("Orange")){ 11 | System.out.println("Price is $4"); 12 | }else if(fruit.equals("Apple")){ 13 | System.out.println("Price is $1000"); 14 | }else if(fruit.equals("Kiwi")){ 15 | System.out.println("$6"); 16 | }else { 17 | System.out.println("This Fruit is not available right now"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/class3/E1TypeCasting.java: -------------------------------------------------------------------------------- 1 | package class3; 2 | 3 | public class E1TypeCasting { 4 | 5 | public static void main(String[] args) { 6 | //byte->short->int->long->float->double 7 | long age=122151512515151L; 8 | 9 | // byte myAge=age; 10 | byte number=10; 11 | int number2=number; 12 | System.out.println(number2); 13 | 14 | float num1=15.6f; 15 | int num2; 16 | num2=(int)num1; 17 | 18 | System.out.println(num2); 19 | 20 | 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/class3/E2TypeCasting.java: -------------------------------------------------------------------------------- 1 | package class3; 2 | 3 | public class E2TypeCasting { 4 | 5 | public static void main(String[] args) { 6 | //byte->short->int->long->float->double 7 | 8 | float box1=15.12564855F; 9 | 10 | int box2; 11 | box2=(int)box1; // type casting narrowing/explicit/manual 12 | System.out.println(box2); 13 | 14 | 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/class3/E3TypeCasting.java: -------------------------------------------------------------------------------- 1 | package class3; 2 | 3 | public class E3TypeCasting { 4 | public static void main(String[] args) { 5 | 6 | int number=100; 7 | byte number2; 8 | number2=(byte)number; 9 | System.out.println(number2); 10 | 11 | short box1=2000; 12 | int box2=box1; //implicit/auto 13 | System.out.println(box2); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/class3/E4RelationalOperators.java: -------------------------------------------------------------------------------- 1 | package class3; 2 | 3 | public class E4RelationalOperators { 4 | public static void main(String[] args) { 5 | 6 | System.out.println(15>10); 7 | System.out.println(15>20); 8 | // performed a relational operation stored them in result variable 9 | boolean result=100>205; 10 | System.out.println(result); 11 | String a="Aladin"; 12 | String b="Deeplai"; 13 | // System.out.println(a>b); 14 | // System.out.println(true>false); 15 | System.out.println('C'>'B'); //true 67>66 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/class3/E5RelationalOperators.java: -------------------------------------------------------------------------------- 1 | package class3; 2 | 3 | public class E5RelationalOperators { 4 | public static void main(String[] args) { 5 | System.out.println(10>15); // is 10 greater than 15 =false 6 | System.out.println(10<15); // is 10 smaller than 15 true 7 | System.out.println(10==15); // is 10 equal to 15 false 8 | System.out.println(10!=15); // is 10 not equal to 15 true 9 | System.out.println(10>=15); // is 10 greater than or equal to 15 false 10 | System.out.println(10<=15); // is 10 less than or equal to 15 true or false true 11 | 12 | // break till 11:56 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/class3/E6IfElseStatements.java: -------------------------------------------------------------------------------- 1 | package class3; 2 | 3 | public class E6IfElseStatements { 4 | public static void main(String[] args) { 5 | 6 | int age = 18; 7 | 8 | if (age > 15) { //16>15=false 9 | System.out.println("You can drive"); 10 | } else { 11 | System.out.println("You can't drive"); 12 | } 13 | 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class3/E7IfElseStatements.java: -------------------------------------------------------------------------------- 1 | package class3; 2 | 3 | public class E7IfElseStatements { 4 | public static void main(String[] args) { 5 | 6 | double accountBalance=1800; 7 | double price=1000; 8 | if(accountBalance>=price){ //800>=1000 false 9 | System.out.println("You can buy this item"); 10 | }else { 11 | System.out.println("You need to save more"); 12 | } 13 | 14 | 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/class3/E8IfElseStatements.java: -------------------------------------------------------------------------------- 1 | package class3; 2 | 3 | public class E8IfElseStatements { 4 | public static void main(String[] args) { 5 | 6 | int batch=17; 7 | boolean f=true; 8 | int age=10; 9 | if(age>20) 10 | System.out.println("Greatest Batch"); 11 | 12 | 13 | 14 | 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/class3/Notes: -------------------------------------------------------------------------------- 1 | Type Casting: 2 | -------------------------------------------------------------------------------- /src/main/java/class3/T1DoubleComparison.java: -------------------------------------------------------------------------------- 1 | package class3; 2 | /* 3 | Create a Java program and name it Double Comparison. 4 | Declare 2 double variables and if value of first variable is higher than the 5 | second, print “Double value __ is larger than __ .” 6 | */ 7 | public class T1DoubleComparison { 8 | public static void main(String[] args) { 9 | double value1=15.5; 10 | double value2=10.9; 11 | if(value1>value2){ 12 | System.out.println("Double value "+value1+" is larger than "+value2); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/class3/T2TemperatureCheck.java: -------------------------------------------------------------------------------- 1 | package class3; 2 | /* 3 | Create a Java program and name it Temperature Check. 4 | Create variable to store temperature. Your program should check if 5 | temperature is below 32 then it should print “Water will freeze with 6 | temperature __”, otherwise “Water will NOT freeze with temperature __”. 7 | */ 8 | public class T2TemperatureCheck { 9 | public static void main(String[] args) { 10 | double temperature=25; 11 | 12 | if(temperature<32) { //25<32=true 13 | System.out.println("Water will freeze with temperature "+temperature); 14 | } else { 15 | System.out.println("Water will NOT freeze with temperature "+temperature); 16 | } 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/class3/T3.java: -------------------------------------------------------------------------------- 1 | package class3; 2 | /* 3 | Create Java program to store 2 values for expected and actual hours. Your program should check 4 | if actual hours are more than expected hours the program should print “You will love the course and 5 | you will succeed”, 6 | otherwise “Course will be very hard for you!” 7 | 8 | */ 9 | public class T3 { 10 | public static void main(String[] args) { 11 | double expectedHour=20; 12 | double actualHour=25; 13 | if(actualHour>expectedHour){ 14 | System.out.println("You will love the course and you will succeed"); 15 | }else { 16 | System.out.println("Course will be very hard for you!"); 17 | } 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/class4/Debugger.java: -------------------------------------------------------------------------------- 1 | package class4; 2 | 3 | public class Debugger { 4 | public static void main(String[] args) { 5 | System.out.println(1); 6 | System.out.println(2); 7 | System.out.println(3); 8 | System.out.println(4); 9 | System.out.println(5); 10 | System.out.println(6); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/class4/E1IfElseStatements.java: -------------------------------------------------------------------------------- 1 | package class4; 2 | 3 | public class E1IfElseStatements { 4 | public static void main(String[] args) { 5 | 6 | int age=10; 7 | String name="jon"; 8 | // boolean condition=age>5; 9 | boolean condition=name.equals("Adam"); 10 | if(condition){ 11 | System.out.println(1); 12 | }else { 13 | System.out.println(2); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class4/E2NestedIf.java: -------------------------------------------------------------------------------- 1 | package class4; 2 | 3 | public class E2NestedIf { 4 | public static void main(String[] args) { 5 | // Break till 11:56 6 | boolean winter = true; 7 | String jacketColor = "Black"; 8 | 9 | if (winter == true) { 10 | System.out.println("Its Very cold"); 11 | if (jacketColor.equals("Red")) { 12 | System.out.println("Lets go with Red Nike shoes"); 13 | } else { 14 | System.out.println("Lets go with the blue ones"); 15 | } 16 | } else { 17 | System.out.println("No need to wear jackets"); 18 | 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/class4/E3NestedIfElse.java: -------------------------------------------------------------------------------- 1 | package class4; 2 | 3 | public class E3NestedIfElse { 4 | public static void main(String[] args) { 5 | 6 | double accountBalance=15000; 7 | 8 | if(accountBalance>28000){ //30k>28k 9 | System.out.println("We can afford a normal toyota"); 10 | if(accountBalance>50000){ 11 | System.out.println("we can also afford Luxury cars as well"); 12 | } 13 | }else { 14 | System.out.println("We need to save more"); 15 | } 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/class4/E5Scanner.java: -------------------------------------------------------------------------------- 1 | package class4; 2 | 3 | import java.util.Scanner; 4 | 5 | public class E5Scanner { 6 | public static void main(String[] args) { 7 | Scanner scanner=new Scanner(System.in); 8 | System.out.println("Please Enter your age"); 9 | int age=scanner.nextInt(); 10 | System.out.println("Your Age is "+age); 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/class4/E6Scanner.java: -------------------------------------------------------------------------------- 1 | package class4; 2 | 3 | import java.util.Scanner; 4 | 5 | public class E6Scanner { 6 | public static void main(String[] args) { 7 | 8 | Scanner scanner=new Scanner(System.in); 9 | System.out.println("Please Enter your Gender F=Female M=Male"); 10 | char gender=scanner.next().charAt(0); 11 | 12 | System.out.println("Your Gender is "+gender); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/class4/E7Scanner.java: -------------------------------------------------------------------------------- 1 | package class4; 2 | 3 | import java.util.Scanner; 4 | 5 | public class E7Scanner { 6 | public static void main(String[] args) { 7 | 8 | Scanner scanner = new Scanner(System.in); 9 | System.out.println("Please Enter your Full name"); 10 | String name = scanner.nextLine(); 11 | System.out.println("Your Full name is "+name); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/class4/Notes: -------------------------------------------------------------------------------- 1 | If else statements: 2 | If else statements help us write code that can take a decision based on a 3 | value and can execute selective code. They work based on a boolean value. 4 | -------------------------------------------------------------------------------- /src/main/java/class5/E1NotOperator.java: -------------------------------------------------------------------------------- 1 | package class5; 2 | 3 | public class E1NotOperator { 4 | public static void main(String[] args) { 5 | 6 | boolean box =false; 7 | box =!box ; 8 | System.out.println(!box ); 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/class5/E2NotOperator.java: -------------------------------------------------------------------------------- 1 | package class5; 2 | 3 | public class E2NotOperator { 4 | public static void main(String[] args) { 5 | 6 | /* 7 | write a program that checks if the country is not equal to Iran 8 | its says you are allowed 9 | */ 10 | String country="UK"; 11 | 12 | if(!country.equals("Iran")){ 13 | System.out.println("Welcome you are allowed"); 14 | } 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/class5/E3NotOperator.java: -------------------------------------------------------------------------------- 1 | package class5; 2 | 3 | import java.util.Scanner; 4 | 5 | public class E3NotOperator { 6 | public static void main(String[] args) { 7 | 8 | Scanner input=new Scanner(System.in); 9 | System.out.println("Please Enter the name of the country"); 10 | String country=input.nextLine(); 11 | 12 | if(!country.equals("Iran")){ 13 | System.out.println("Welcome you are allowed"); 14 | } 15 | 16 | if(!country.equalsIgnoreCase("Iran")){ 17 | System.out.println("Welcome you are allowed"); 18 | } 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/class5/E4OROperator.java: -------------------------------------------------------------------------------- 1 | package class5; 2 | 3 | public class E4OROperator { 4 | public static void main(String[] args) { 5 | 6 | boolean cond1=false; 7 | boolean cond2=false; 8 | boolean cond3=false; 9 | boolean result=cond1 ||cond2||cond3; 10 | System.out.println(result); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/class5/E5OROperator.java: -------------------------------------------------------------------------------- 1 | package class5; 2 | 3 | public class E5OROperator { 4 | public static void main(String[] args) { 5 | 6 | boolean broughtFlowers=false; 7 | boolean broughtChocolates=false; 8 | boolean allMyMistake=false; 9 | 10 | if(broughtChocolates||broughtFlowers||allMyMistake){ 11 | System.out.println("Wife is happy"); 12 | }else { 13 | System.out.println("Wife is Sad"); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class5/E6OROperator.java: -------------------------------------------------------------------------------- 1 | package class5; 2 | /* 3 | 4 | 5 | Break till 11:50 6 | 7 | */ 8 | public class E6OROperator { 9 | public static void main(String[] args) { 10 | 11 | String genre="thriller"; 12 | if(genre.equals("thriller")||genre.equals("HORROR")||genre.equals("sci fi")){ 13 | System.out.println("I am going to watch this movie"); 14 | }else { 15 | System.out.println("I don't like this genre"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/class5/E7ANDOperator.java: -------------------------------------------------------------------------------- 1 | package class5; 2 | 3 | public class E7ANDOperator { 4 | public static void main(String[] args) { 5 | 6 | boolean cond1=true; 7 | boolean cond2=true; 8 | boolean cond3=true; 9 | boolean cond4=true; 10 | boolean result=cond1&&cond2&&cond3&&cond4; 11 | System.out.println(result); 12 | 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/class5/E8ANDOperator.java: -------------------------------------------------------------------------------- 1 | package class5; 2 | 3 | public class E8ANDOperator { 4 | public static void main(String[] args) { 5 | 6 | 7 | boolean goodCredit=false; 8 | boolean stableJob=true; 9 | boolean minimumAge=false; 10 | if(goodCredit&&stableJob&&minimumAge){ 11 | System.out.println("You can have the loan"); 12 | }else { 13 | System.out.println("You need to fulfill all the requirements"); 14 | } 15 | 16 | 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/class5/E9ANDOperator.java: -------------------------------------------------------------------------------- 1 | package class5; 2 | 3 | public class E9ANDOperator { 4 | public static void main(String[] args) { 5 | 6 | 7 | double math=92; 8 | double physics=89; 9 | double chemistry=91; 10 | if(math>90 && physics>90 && chemistry>90){ 11 | System.out.println("You are doing great"); 12 | }else { 13 | System.out.println("You need to work harder"); 14 | } 15 | 16 | 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/class5/StaticTester.java: -------------------------------------------------------------------------------- 1 | package class5; 2 | 3 | import review8.E3StaticVar; 4 | 5 | public class StaticTester { 6 | public static void main(String[] args) { 7 | System.out.println(E3StaticVar.country); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/class5/T3ANDOROperator.java: -------------------------------------------------------------------------------- 1 | package class5; 2 | 3 | /* 4 | Write a program that will print whether it is a weekend or weekday. 5 | If any day from 1-5 → output “It is a weekday”, anyday from 6-7 → output 6 | “It is a weekend”, any other day → output “Invalid day” 7 | // Break till 1:53 8 | */ 9 | public class T3ANDOROperator { 10 | public static void main(String[] args) { 11 | int day=5; 12 | if(day>=1 && day<=5){ 13 | System.out.println("It is a weekday"); 14 | } else if (day==6|| day==7) { 15 | System.out.println("It is a weekend"); 16 | }else { 17 | System.out.println("Invalid Day"); 18 | } 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/class6/E10WhileLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | import java.util.Scanner; 4 | 5 | public class E10WhileLoop { 6 | public static void main(String[] args) { 7 | Scanner scanner=new Scanner(System.in); 8 | System.out.println("Please Enter the starting point"); 9 | int start = scanner.nextInt(); 10 | System.out.println("Please Enter the ending point"); 11 | int end = scanner.nextInt(); 12 | System.out.println("Please Enter the steps as well"); 13 | int step = scanner.nextInt(); 14 | while (start <= end) { 15 | System.out.print(start+" "); 16 | start += step; 17 | } 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/class6/E11DoWhileLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class E11DoWhileLoop { 4 | public static void main(String[] args) { 5 | // Break till 1:51 6 | int i=1; 7 | 8 | do{ 9 | System.out.print(i+" "); 10 | i++; 11 | }while (i<=10); 12 | 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/class6/E12DoWhileLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | import java.util.Scanner; 4 | 5 | public class E12DoWhileLoop { 6 | public static void main(String[] args) { 7 | // Break till 1:51 8 | Scanner scanner = new Scanner(System.in); 9 | int input; 10 | do { 11 | System.out.println("Please Enter a number or -1 to terminate"); 12 | input = scanner.nextInt(); 13 | System.out.println("You have entered "+input ); 14 | } while (input!=-1); 15 | 16 | 17 | 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/class6/E13DoWhileLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | import java.util.Scanner; 4 | 5 | public class E13DoWhileLoop { 6 | public static void main(String[] args) { 7 | // Break till 1:51 8 | Scanner scanner = new Scanner(System.in); 9 | int input; 10 | System.out.println("Please Enter a number or -1 to terminate"); 11 | input = scanner.nextInt(); 12 | System.out.println("You have entered "+input ); 13 | while (input != -1) { 14 | System.out.println("Please Enter a number or -1 to terminate"); 15 | input = scanner.nextInt(); 16 | System.out.println("You have entered " + input); 17 | } 18 | 19 | 20 | 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/class6/E14ForLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class E14ForLoop { 4 | public static void main(String[] args) { 5 | 6 | /* int i=1; 7 | while (i<=10){ 8 | System.out.print(i+" "); 9 | i++; 10 | }*/ 11 | 12 | for(int i=1;i<=10;i++){ 13 | System.out.print(i+" "); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class6/E1IncrementOperators.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class E1IncrementOperators { 4 | public static void main(String[] args) { 5 | int age = 100; 6 | //++age; 7 | System.out.println(age++); 8 | System.out.println(age); 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/class6/E2IncrementOperators.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class E2IncrementOperators { 4 | public static void main(String[] args) { 5 | int age = 100; 6 | age++; // 101 7 | age++; // 102 8 | age--; //101 9 | System.out.println(age); 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/class6/E3WhileLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class E3WhileLoop { 4 | public static void main(String[] args) { 5 | // without loops, we have to copy and paste the code if we want to repeat something 6 | System.out.println("Hello World"); 7 | System.out.println("Hello World"); 8 | System.out.println("Hello World"); 9 | System.out.println("Hello World"); 10 | System.out.println("Hello World"); 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/class6/E4WhileLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class E4WhileLoop { 4 | public static void main(String[] args) { 5 | 6 | int i=5; 7 | while(i>4){ 8 | System.out.println("Hello World"); 9 | i++; 10 | } 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/class6/E5WhileLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class E5WhileLoop { 4 | public static void main(String[] args) { 5 | // Break till 11:50 6 | 7 | int i=5; 8 | while(10>=i){ 9 | i++; 10 | System.out.println(i); 11 | 12 | } 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/class6/E6WhileLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class E6WhileLoop { 4 | public static void main(String[] args) { 5 | 6 | 7 | int i = 10; 8 | while (i >= 1) { 9 | 10 | System.out.println(i); 11 | i--; 12 | } 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/class6/E7WhileLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class E7WhileLoop { 4 | public static void main(String[] args) { 5 | 6 | 7 | int i = 10; 8 | while (i >= 1) { 9 | 10 | System.out.println(i); 11 | i-=2; 12 | } 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/class6/E8WhileLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class E8WhileLoop { 4 | public static void main(String[] args) { 5 | 6 | 7 | int i = 1; 8 | while (i <= 10) { 9 | if (i != 7) { 10 | System.out.print(i+" "); 11 | } 12 | i++; 13 | } 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class6/E9WhileLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class E9WhileLoop { 4 | public static void main(String[] args) { 5 | 6 | 7 | int start = 5; 8 | int end = 15; 9 | int step = 3; 10 | while (start <= end) { 11 | System.out.print(start+" "); 12 | start += step; 13 | } 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class6/T10ForLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class T10ForLoop { 4 | public static void main(String[] args) { 5 | // Print even numbers from 20 to 100 6 | for (int i = 20; i<=100 ; i+=2) { 7 | System.out.print(i+" "); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/class6/T11ForLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class T11ForLoop { 4 | public static void main(String[] args) { 5 | // Print only odd numbers from 100 to 1 6 | //(2 different way) 7 | for (int i = 99; i>=1 ; i-=2) { 8 | System.out.print(i+" "); 9 | } 10 | System.out.println(); 11 | int y=99; 12 | 13 | while (y>=1){ 14 | System.out.print(y+" "); 15 | y-=2; 16 | } 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/class6/T1WhileLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class T1WhileLoop { 4 | public static void main(String[] args) { 5 | /* 6 | write a while loop that prints numbers from 1 to 10. 7 | */ 8 | 9 | int i=1; 10 | 11 | while (i<=10){ 12 | System.out.println(i); 13 | i++; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class6/T2WhileLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class T2WhileLoop { 4 | public static void main(String[] args) { 5 | /* 6 | write a while loop that prints numbers from 10 to 20. 7 | */ 8 | 9 | int i=10; 10 | 11 | while (i<=20){ 12 | System.out.println(i); 13 | i++; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class6/T3WhileLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class T3WhileLoop { 4 | public static void main(String[] args) { 5 | /* 6 | print 10 12 14 16 18 20 7 | */ 8 | 9 | int i=10; 10 | 11 | while (i<=20){ 12 | System.out.println(i); 13 | i+=2; //i++;i++ i+=2 i=i+2 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class6/T4WhileLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class T4WhileLoop { 4 | public static void main(String[] args) { 5 | /* 6 | print 1 3 5 7 9 11 7 | */ 8 | 9 | int i=1; // starting point 10 | while (i<=11){ // ending point 11 | System.out.println(i); 12 | i+=2; // steps 13 | } 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class6/T5WhileLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class T5WhileLoop { 4 | public static void main(String[] args) { 5 | /* 6 | print 5 10 15 20 25 30 7 | */ 8 | 9 | int i=5; // starting point 10 | while (i<=30){ // ending point 11 | System.out.println(i); 12 | i+=5; // steps 13 | } 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class6/T6WhileLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class T6WhileLoop { 4 | public static void main(String[] args) { 5 | /* 6 | print all the even numbers from 2 to 100 7 | */ 8 | 9 | int i=2; // starting point 10 | while (i<=100){ // ending point 11 | System.out.print(i+" "); 12 | i+=2; // steps 13 | } 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class6/T7DoWhileLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class T7DoWhileLoop { 4 | public static void main(String[] args) { 5 | /* 6 | print all the even numbers from 2 to 20 use Do while loop 7 | */ 8 | int i=2; 9 | do{ 10 | System.out.print(i+" "); 11 | i+=2; 12 | }while (i<=20); 13 | 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class6/T8ForLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class T8ForLoop { 4 | public static void main(String[] args) { 5 | // print numbers from 2 to 24 using for loop 6 | for (int i = 2; i <=24 ; i++) { 7 | System.out.println(i); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/class6/T9ForLoop.java: -------------------------------------------------------------------------------- 1 | package class6; 2 | 3 | public class T9ForLoop { 4 | public static void main(String[] args) { 5 | // print numbers from 2 to 24 using for loop 6 | for (int i = 100; i >=1 ; i--) { 7 | System.out.print(i+" "); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/class7/E10Arrays.java: -------------------------------------------------------------------------------- 1 | package class7; 2 | 3 | public class E10Arrays { 4 | public static void main(String[] args) { 5 | //creating the array and also initializing it 6 | String [] fruit={"Apple","Orange","Banana","Kiwi","PineApple"}; 7 | 8 | fruit[3]="Mango"; 9 | 10 | for (int i = 0; i < fruit.length; i++) { 11 | System.out.println(fruit[i]); 12 | } 13 | 14 | 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/class7/E11Arrays.java: -------------------------------------------------------------------------------- 1 | package class7; 2 | 3 | public class E11Arrays { 4 | public static void main(String[] args) { 5 | // only creating the array 6 | int [] prices= new int[5]; 7 | prices[0]=1000; 8 | prices[2]=250; 9 | prices[2]=234; 10 | 11 | System.out.println(prices[2]); 12 | 13 | 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class7/E1NestedLoops.java: -------------------------------------------------------------------------------- 1 | package class7; 2 | 3 | public class E1NestedLoops { 4 | public static void main(String[] args) { 5 | 6 | for (int i = 0; i <5 ; i++) { 7 | System.out.print("+"); 8 | } 9 | System.out.println(); 10 | for (int i = 0; i <5 ; i++) { 11 | System.out.print("+"); 12 | } 13 | 14 | System.out.println(); 15 | for (int i = 0; i <5 ; i++) { 16 | System.out.print("+"); 17 | } 18 | 19 | System.out.println(); 20 | for (int i = 0; i <5 ; i++) { 21 | System.out.print("+"); 22 | } 23 | 24 | System.out.println(); 25 | for (int i = 0; i <5 ; i++) { 26 | System.out.print("+"); 27 | } 28 | 29 | 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/class7/E2NestedLoops.java: -------------------------------------------------------------------------------- 1 | package class7; 2 | 3 | public class E2NestedLoops { 4 | public static void main(String[] args) { 5 | 6 | 7 | 8 | 9 | for (int j = 0; j < 2; j++) { 10 | 11 | for (int i = 0; i <10 ; i++) { 12 | System.out.print("+"); 13 | } 14 | System.out.println(); 15 | } 16 | 17 | 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/class7/E3NestedLoops.java: -------------------------------------------------------------------------------- 1 | package class7; 2 | 3 | public class E3NestedLoops { 4 | public static void main(String[] args) { 5 | 6 | 7 | for (int j = 0; j <3 ; j++) { 8 | for (int i = 2; i < 20; i=i+2) { 9 | System.out.print(i+" "); 10 | } 11 | System.out.println(); 12 | } 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/class7/E4NestedLoops.java: -------------------------------------------------------------------------------- 1 | package class7; 2 | 3 | public class E4NestedLoops { 4 | public static void main(String[] args) { 5 | 6 | // 11:50 7 | 8 | int y=1; 9 | while (y<=3){ 10 | 11 | int x=1; 12 | while (x<=20){ 13 | System.out.print("="); 14 | x++; 15 | } 16 | System.out.println(); 17 | y++; 18 | } 19 | 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/class7/E5NestedLoops.java: -------------------------------------------------------------------------------- 1 | package class7; 2 | 3 | public class E5NestedLoops { 4 | public static void main(String[] args) { 5 | 6 | for (int i = 0; i < 4; i++) { 7 | 8 | for (int j = 0; j < 3; j++) { 9 | System.out.print(i+" "); 10 | } 11 | System.out.println(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/class7/E6NestedLoops.java: -------------------------------------------------------------------------------- 1 | package class7; 2 | 3 | public class E6NestedLoops { 4 | /* 5 | # 6 | * ## 7 | * #### 8 | * ##### 9 | * ###### 10 | */ 11 | public static void main(String[] args) { 12 | // 0 1 2 3 4 5 13 | 14 | for (int j = 0; j <=5 ; j++) { 15 | for (int i = 0; i <=j ; i++) { 16 | System.out.print("*"); 17 | } 18 | System.out.println(); 19 | } 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/class7/E7Arrays.java: -------------------------------------------------------------------------------- 1 | package class7; 2 | 3 | public class E7Arrays { 4 | public static void main(String[] args) { 5 | String name="Shawn"; 6 | String name2="Hind"; 7 | String [] names={"Ahmed","Ali","Hind","Mike"}; 8 | System.out.println(name); 9 | System.out.println(names[3]); 10 | 11 | 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/class7/E8Arrays.java: -------------------------------------------------------------------------------- 1 | package class7; 2 | 3 | public class E8Arrays { 4 | public static void main(String[] args) { 5 | int[] ages = {22, 25, 18, 30}; 6 | // System.out.println(ages[2]); 7 | 8 | for (int i = 0; i < 4; i++) { 9 | System.out.println(ages[i]); 10 | } 11 | 12 | 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/class7/E9Arrays.java: -------------------------------------------------------------------------------- 1 | package class7; 2 | 3 | public class E9Arrays { 4 | public static void main(String[] args) { 5 | String [] fruit={"Apple","Orange","Banana","Kiwi","PineApple"}; 6 | System.out.println(fruit.length); // gives us the number of items in the array 7 | for (int i = 0; i < fruit.length; i++) { 8 | System.out.println(fruit[i]); 9 | } 10 | 11 | 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/class7/Notes: -------------------------------------------------------------------------------- 1 | NestedLoops: 2 | A loop inside another loop. just like nested if statements. We can nest 3 | any type of loop. 4 | Why we do we need them? 5 | To solve complex problems that requires accessing nested data. 6 | Arrays: 7 | Array is a datastructures that helps us store multiple items in a single 8 | variable. We can use the indexes to access these values. 9 | -------------------------------------------------------------------------------- /src/main/java/class7/T1NestedLoops.java: -------------------------------------------------------------------------------- 1 | package class7; 2 | 3 | public class T1NestedLoops { 4 | /* 5 | 1 2 3 4 5 6 6 | 1 2 3 4 5 6 7 | 1 2 3 4 5 6 8 | 1 2 3 4 5 6 9 | */ 10 | public static void main(String[] args) { 11 | 12 | for (int i = 0; i < 4; i++) { 13 | for (int j = 1; j <7 ; j++) { 14 | System.out.print(j+" "); 15 | } 16 | System.out.println(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/class7/T2NestedLoops.java: -------------------------------------------------------------------------------- 1 | package class7; 2 | 3 | public class T2NestedLoops { 4 | /* 5 | 1 2 4 5 6 6 | 1 2 4 5 6 7 | 1 2 4 5 6 8 | 1 2 4 5 6 9 | */ 10 | public static void main(String[] args) { 11 | 12 | for (int i = 0; i < 4; i++) { 13 | for (int j = 1; j < 7; j++) { 14 | if (j != 3) { 15 | System.out.print(j + " "); 16 | } 17 | } 18 | System.out.println(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/class7/T3NestedLoops.java: -------------------------------------------------------------------------------- 1 | package class7; 2 | 3 | public class T3NestedLoops { 4 | /* 5 | 1 2 4 5 6 6 | 1 2 4 5 6 7 | 1 2 4 5 6 8 | 1 2 4 5 6 9 | */ 10 | public static void main(String[] args) { 11 | 12 | int i = 0; 13 | while (i < 4) { 14 | int j = 1; 15 | while (j < 7) { 16 | if (j != 3) { 17 | System.out.print(j + " "); 18 | } 19 | j++; 20 | } 21 | System.out.println(); 22 | i++; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/class7/T4NestedLoops.java: -------------------------------------------------------------------------------- 1 | package class7; 2 | 3 | public class T4NestedLoops { 4 | /* 5 | 1 1 6 | 1 2 7 | 1 3 8 | 2 1 9 | 2 2 10 | 2 3 11 | 3 1 12 | 3 2 13 | 3 3 14 | */ 15 | public static void main(String[] args) { 16 | for (int i = 1; i <=3 ; i++) { 17 | for (int j = 1; j <=3 ; j++) { 18 | System.out.println(i+" "+j); 19 | } 20 | } 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/class7/T5NestedLoops.java: -------------------------------------------------------------------------------- 1 | package class7; 2 | 3 | public class T5NestedLoops { 4 | /* 5 | ###### 6 | ## ## 7 | ## ## 8 | ###### 9 | */ 10 | public static void main(String[] args) { 11 | // 1:34 12 | for (int i = 1; i <=4 ; i++) { 13 | for (int j = 1; j <=6 ; j++) { 14 | if(i==2&&j==3||i==3&&j==3 ||i==2&&j==4||i==3&&j==4){ 15 | System.out.print(" "); 16 | }else { 17 | System.out.print("#"); 18 | } 19 | } 20 | System.out.println(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/class7/T6Arrays.java: -------------------------------------------------------------------------------- 1 | package class7; 2 | 3 | public class T6Arrays { 4 | /* 5 | create an array store 5 numbers in it and print all the numbers from the array 6 | */ 7 | public static void main(String[] args) { 8 | int [] numbers={20,29,48,69,60}; //20,48,60 9 | 10 | for (int i = 0; i < numbers.length; i++) { 11 | System.out.println(numbers[i]); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/class7/T7Arrays.java: -------------------------------------------------------------------------------- 1 | package class7; 2 | 3 | public class T7Arrays { 4 | /* 5 | create an array store 5 numbers in it and print all the numbers from the array 6 | */ 7 | public static void main(String[] args) { 8 | int [] numbers={20,24,48,69,60}; //20,48,60 9 | 10 | for (int i = 0; i < numbers.length; i++) { 11 | if(numbers[i]%2!=0){ 12 | System.out.println(numbers[i]);} 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/class7/T8Arrays.java: -------------------------------------------------------------------------------- 1 | package class7; 2 | 3 | public class T8Arrays { 4 | /* 5 | Add all the numbers from the array and print the sum at the end. 6 | */ 7 | public static void main(String[] args) { 8 | int [] numbers={20,10,50,30,40}; //150 9 | 10 | int sum=0; 11 | for (int i = 0; i < numbers.length; i++) { 12 | sum=sum+numbers[i]; //pick the previous value of sum and add it to current value of array 13 | } 14 | System.out.println(sum); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class8/E10ContinueKeyword.java: -------------------------------------------------------------------------------- 1 | package class8; 2 | 3 | public class E10ContinueKeyword { 4 | public static void main(String[] args) { 5 | 6 | for (int i = 0; i < 10; i++) { 7 | 8 | System.out.println("Batch 17 is Greatest of all time"); 9 | if(i%2==0){ 10 | continue; //skip 11 | } 12 | System.out.println("I am was kidding"); 13 | } 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class8/E1Arrays.java: -------------------------------------------------------------------------------- 1 | package class8; 2 | 3 | public class E1Arrays { 4 | public static void main(String[] args) { 5 | 6 | char [] chars={'A','b','c','F','E','#','@'}; 7 | 8 | for (int i = 0; i < chars.length; i++) { 9 | System.out.println(chars[i]); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/class8/E2Arrays.java: -------------------------------------------------------------------------------- 1 | package class8; 2 | 3 | public class E2Arrays { 4 | public static void main(String[] args) { 5 | 6 | boolean [] conds={true,false,true,false,true,true}; 7 | 8 | int i=0; 9 | while (i 20) { 11 | count++; 12 | } 13 | } 14 | System.out.println(count); 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/class8/E5EnhancedLoop.java: -------------------------------------------------------------------------------- 1 | package class8; 2 | 3 | public class E5EnhancedLoop { 4 | public static void main(String[] args) { 5 | // print all the even numbers one by one from this array using enhanced for loop 6 | int[] nums = {10, 23, 25, 56, 45, 20}; 7 | for (int number:nums){ 8 | 9 | if(number%2==0){ 10 | System.out.println(number); 11 | } 12 | } 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/class8/E6EnhancedLoop.java: -------------------------------------------------------------------------------- 1 | package class8; 2 | 3 | public class E6EnhancedLoop { 4 | public static void main(String[] args) { 5 | // print all the even numbers one by one from this array using enhanced for loop 6 | int[] nums = {10, 23, 25, 56, 45, 20}; 7 | for (int i = 0; i < nums.length; i++) { 8 | 9 | if(nums[i]>20){ 10 | nums[i]=0; 11 | } 12 | System.out.println(nums[i]); 13 | } 14 | 15 | 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/class8/E7BreakKeyword.java: -------------------------------------------------------------------------------- 1 | package class8; 2 | 3 | public class E7BreakKeyword { 4 | public static void main(String[] args) { 5 | // you have to search the array for number 45 it is present in the array 6 | //print found else do nothing 7 | int[] nums = {10, 23, 25, 56, 45, 20}; 8 | 9 | for (int n : nums) { 10 | if (n == 10) { 11 | System.out.println("Found"); 12 | break; 13 | } 14 | } 15 | 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/class8/E8BreakKeyword.java: -------------------------------------------------------------------------------- 1 | package class8; 2 | 3 | public class E8BreakKeyword { 4 | public static void main(String[] args) { 5 | 6 | for (int i = 0; i < 2; i++) { 7 | 8 | System.out.println("Outer loop"); 9 | for (int j = 0; j < 5; j++) { 10 | 11 | if(j==2){ 12 | break; 13 | } 14 | System.out.println("Inner loop"); 15 | } 16 | 17 | } 18 | 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/class8/E9BreakKeyword.java: -------------------------------------------------------------------------------- 1 | package class8; 2 | 3 | import java.util.Scanner; 4 | 5 | public class E9BreakKeyword { 6 | public static void main(String[] args) { 7 | Scanner scanner = new Scanner(System.in); 8 | double total = 0; 9 | while (true) { 10 | System.out.println("Please Enter the price of the item or -1 to terminate"); 11 | double price = scanner.nextDouble(); 12 | if (price == -1) { 13 | break; 14 | } else { 15 | total = total + price; 16 | } 17 | System.out.println("Your total bill is "+total); 18 | 19 | } 20 | 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/class8/T1Arrays.java: -------------------------------------------------------------------------------- 1 | package class8; 2 | 3 | public class T1Arrays { 4 | public static void main(String[] args) { 5 | 6 | char [] chars={'A','b','c','F','E','#','@'}; 7 | for (int i = chars.length; i >=0 ; i--) { 8 | System.out.println(chars[i]); 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/class8/T2Arrays.java: -------------------------------------------------------------------------------- 1 | package class8; 2 | 3 | public class T2Arrays { 4 | public static void main(String[] args) { 5 | // count how many numbers are greater than 10 in below array 6 | //expected answer 3 7 | // Break till 11:50 8 | int [] numbers={10, 20,4,3,8,45,96}; 9 | int count=0; 10 | for (int i = 0; i < numbers.length; i++) { 11 | 12 | if(numbers[i]>10){ 13 | count++; 14 | } 15 | 16 | } 17 | System.out.println(count); 18 | 19 | 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/class8/T3Arrays.java: -------------------------------------------------------------------------------- 1 | package class8; 2 | 3 | public class T3Arrays { 4 | public static void main(String[] args) { 5 | // Count how many true values are present in array 6 | boolean [] conds={true,false,true,false,true,true}; 7 | int count=0; 8 | for (int i = 0; i < conds.length; i++) { 9 | 10 | if(conds[i]){ 11 | count++; 12 | } 13 | } 14 | System.out.println(count); 15 | 16 | 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/class8/T4EnhancedLoop.java: -------------------------------------------------------------------------------- 1 | package class8; 2 | 3 | public class T4EnhancedLoop { 4 | public static void main(String[] args) { 5 | 6 | int[] nums = {10, 23, 25, 56, 45, 20}; 7 | int largest = nums[0]; 8 | for (int tylorSwift : nums) { 9 | 10 | if (tylorSwift > largest) { 11 | largest = tylorSwift; 12 | } 13 | } 14 | System.out.println(largest); 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/class8/T5EnhancedLoop.java: -------------------------------------------------------------------------------- 1 | package class8; 2 | 3 | public class T5EnhancedLoop { 4 | public static void main(String[] args) { 5 | // find the largest even number 6 | int[] nums = {10, 77, 25, 56, 60, 20}; 7 | int largest=nums[0]; 8 | for(int tahmin:nums){ 9 | if(tahmin>largest&& tahmin%2==0){ 10 | largest=tahmin; 11 | } 12 | } 13 | System.out.println(largest); 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class8/T6EnhancedLoop.java: -------------------------------------------------------------------------------- 1 | package class8; 2 | 3 | public class T6EnhancedLoop { 4 | public static void main(String[] args) { 5 | // find the smallest number expected answer 10 6 | int[] nums = {10, 77, 25, 56, 60, 20, -10, -5}; 7 | int smallest = nums[0]; 8 | for (int n : nums) { 9 | if (n < smallest) { 10 | smallest = n; 11 | } 12 | } 13 | System.out.println(smallest); 14 | 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/class8/T7EnhancedLoop.java: -------------------------------------------------------------------------------- 1 | package class8; 2 | 3 | public class T7EnhancedLoop { 4 | public static void main(String[] args) { 5 | // go through the array and replace all the negative numbers with 0 6 | //Break till 1:54 7 | int[] nums = {10, 77, 25, 56, 60, 20, -10, -5}; 8 | for (int i = 0; i < nums.length; i++) { 9 | 10 | if(nums[i]<0){ 11 | nums[i]=0; 12 | } 13 | } 14 | for (int num : nums) { 15 | System.out.println(num); 16 | } 17 | 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/class9/E12DArrays.java: -------------------------------------------------------------------------------- 1 | package class9; 2 | 3 | public class E12DArrays { 4 | public static void main(String[] args) { 5 | 6 | String[][] names = 7 | { {"Hind", "Mikhail", "Ismael", "Ahmed" }, 8 | {"John", "Bob", "Adam", "Tamim" }, 9 | {"Joke", "Laugh", "John Ahmed", "Mohammad" }, 10 | {"Gui", "Backend", "Front", "API" } 11 | 12 | }; 13 | 14 | System.out.println(names[2][2]); //John Ahmed 15 | System.out.println(names[1][3]); //Tamim 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/class9/E22DArrays.java: -------------------------------------------------------------------------------- 1 | package class9; 2 | 3 | public class E22DArrays { 4 | public static void main(String[] args) { 5 | 6 | String[][] names = 7 | { {"Hind", "Mikhail", "Ismael", "Ahmed" }, 8 | {"John", "Bob", "Adam", "Tamim" }, 9 | {"Joke", "Laugh", "John Ahmed", "Mohammad" }, 10 | {"Gui", "Backend", "Front", "API" } 11 | 12 | }; 13 | 14 | String[] row = names[2]; 15 | // System.out.println(row[3]); 16 | // System.out.println(Arrays.toString(firstRow)); 17 | for(String ahmed:row){ 18 | System.out.println(ahmed); 19 | } 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/class9/E32DArrays.java: -------------------------------------------------------------------------------- 1 | package class9; 2 | 3 | import java.util.Arrays; 4 | 5 | public class E32DArrays { 6 | public static void main(String[] args) { 7 | 8 | /* int [] row0={10,20,30,40}; 9 | int [] row1={100,200,303,400}; 10 | int [] row2={1,2,3,4};*/ 11 | 12 | 13 | 14 | int [][] numbers={ 15 | {10,20,30,40}, 16 | {100,200,303}, 17 | {100,200,303,400}}; 18 | 19 | int [] row=numbers[0]; // this returns us a complete 1D array 20 | int number=numbers[0][1]; // this return us one single element 21 | System.out.println(numbers[0][1]); //20 22 | System.out.println(Arrays.toString(numbers[1])); // complete second row 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/class9/E42DArrays.java: -------------------------------------------------------------------------------- 1 | package class9; 2 | 3 | public class E42DArrays { 4 | public static void main(String[] args) { 5 | 6 | int[][] numbers = { 7 | {10, 20, 30, 40}, 8 | {15, 30, 35, 45}, 9 | {16, 20, 32, 22}}; 10 | 11 | for (int row = 0; row < numbers.length; row++) { 12 | for (int col = 0; col < numbers[row].length; col++) { //numbers[row] => gives us the complete 1D array 13 | System.out.print(numbers[row][col]+" "); 14 | } 15 | System.out.println(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/class9/E52DArrays.java: -------------------------------------------------------------------------------- 1 | package class9; 2 | 3 | public class E52DArrays { 4 | public static void main(String[] args) { 5 | 6 | int[][] numbers = { 7 | {10, 20, 30, 40}, 8 | {15, 30, 35, 45}, 9 | {16, 20, 32, 22}}; 10 | int sum=0; 11 | for (int row = 0; row < numbers.length; row++) { 12 | for (int col = 0; col < numbers[row].length; col++) { 13 | sum=sum+numbers[row][col]; 14 | } 15 | } 16 | 17 | System.out.println(sum); 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/class9/E62DArrays.java: -------------------------------------------------------------------------------- 1 | package class9; 2 | 3 | public class E62DArrays { 4 | public static void main(String[] args) { 5 | 6 | int[][] numbers = { 7 | {10, 20, 30, 40}, 8 | {15, 30, 35, 45}, 9 | {16, 20, 32, 22}}; 10 | 11 | for (int i = 0; i <=3; i++) { 12 | System.out.println(numbers[2][i]); 13 | } 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class9/E72DArrays.java: -------------------------------------------------------------------------------- 1 | package class9; 2 | 3 | public class E72DArrays { 4 | public static void main(String[] args) { 5 | 6 | int[][] numbers = { 7 | {10, 20, 30, 40}, 8 | {15, 30, 35, 45}, 9 | {16, 20, 32, 22}}; 10 | 11 | for (int row = 0; row < numbers.length; row++) { 12 | for (int col = 0; col < numbers[row].length; col++) { 13 | System.out.print(numbers[row][col]+" "); 14 | } 15 | System.out.println(); 16 | } 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/class9/E82DArrays.java: -------------------------------------------------------------------------------- 1 | package class9; 2 | 3 | public class E82DArrays { 4 | public static void main(String[] args) { 5 | 6 | int[][] numbers = { 7 | {10, 20, 30, 40}, 8 | {15, 30, 35, 45}, 9 | {16, 20, 32, 22}}; 10 | 11 | for (int[] row : numbers) { 12 | 13 | for (int col : row) { 14 | System.out.print(col+" "); 15 | } 16 | System.out.println(); 17 | } 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/class9/E92DArrays.java: -------------------------------------------------------------------------------- 1 | package class9; 2 | 3 | import java.util.Arrays; 4 | 5 | public class E92DArrays { 6 | public static void main(String[] args) { 7 | 8 | String[][] names = 9 | { {"Hind", "Mikhail", "Ismael", "Ahmed" }, 10 | {"John", "Bob", "Adam", "Tamim" }, 11 | {"Joke", "Laugh", "John Ahmed", "Mohammad" }, 12 | {"Gui", "Backend", "Front", "API" } 13 | 14 | }; 15 | 16 | for(String [] row:names){ 17 | for(String v:row){ 18 | System.out.print(v+" "); 19 | } 20 | System.out.println(); 21 | } 22 | System.out.println(Arrays.deepToString(names)); // for printing 2D arrays 23 | 24 | 25 | 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/class9/Notes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SyntaxTechnologies/SDETBatch17/568a3c49224a4a8f9ee55520f650458f73532cc5/src/main/java/class9/Notes -------------------------------------------------------------------------------- /src/main/java/class9/T12DArrays.java: -------------------------------------------------------------------------------- 1 | package class9; 2 | 3 | public class T12DArrays { 4 | public static void main(String[] args) { 5 | // print only even numbers from this array 6 | int[][] numbers = { 7 | {10, 20, 30, 40}, 8 | {15, 30, 35, 45}, 9 | {16, 20, 32, 22}}; 10 | 11 | for (int row = 0; row < numbers.length; row++) { 12 | for (int col = 0; col < numbers[row].length; col++) { //numbers[row] => gives us the complete 1D array 13 | if (numbers[row][col] % 2 == 0) { 14 | System.out.print(numbers[row][col] + " "); 15 | } 16 | } 17 | System.out.println(); 18 | } 19 | } // Break till 11:48 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/class9/T22DArrays.java: -------------------------------------------------------------------------------- 1 | package class9; 2 | 3 | public class T22DArrays { 4 | public static void main(String[] args) { 5 | 6 | int[][] numbers = { 7 | {10, 20, 30, 40,50}, 8 | {15, 30, 35, 45,20}, 9 | {16, 20, 32, 22,30}}; 10 | // write a loop to get all the elements from second row one by one 11 | for (int i = 0; i <5 ; i++) { 12 | System.out.println(numbers[1][i]); 13 | } 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/class9/T32DArrays.java: -------------------------------------------------------------------------------- 1 | package class9; 2 | 3 | /* 4 | Create a 2D array(shorter way) in which first array will 5 | consist of 4 names and second array will contain grades. 6 | Then your program should print name of the students that has A and B grade 7 | */ 8 | public class T32DArrays { 9 | public static void main(String[] args) { 10 | String[][] students = { 11 | {"Aysha", "Giulia", "John", "Deepali" }, 12 | {"A", "A+", "C", "B" } 13 | }; 14 | for (int i = 0; i < students[0].length; i++) { 15 | if(students[1][i].equals("A") ||students[1][i].equals("B")){ 16 | System.out.println(students[0][i]);} 17 | } 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/review1/E1Variables.java: -------------------------------------------------------------------------------- 1 | package review1; 2 | 3 | public class E1Variables { 4 | 5 | public static void main(String[] args) { 6 | String browser="Firefox"; 7 | String url="www.amazon.com"; 8 | System.out.println("Open "+browser); 9 | System.out.println("Go to "+url); 10 | System.out.println("Click on the logo"); 11 | System.out.println("Click on the login page"); 12 | 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/review1/E2Variables.java: -------------------------------------------------------------------------------- 1 | package review1; 2 | 3 | public class E2Variables { 4 | public static void main(String[] args) { 5 | /* 6 | we are creating a variable of type int 7 | we are calling it age 8 | we are storing number 10 inside that variable 9 | we are declaring a variable of type int and assigning 10 to it. 10 | */ 11 | int age=10; 12 | age=12; // reassigning the number 12 to age variable 13 | System.out.println(age); 14 | int price; 15 | price=1000; 16 | System.out.println(price); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/review1/E3Variables.java: -------------------------------------------------------------------------------- 1 | package review1; 2 | 3 | public class E3Variables { 4 | public static void main(String[] args) { 5 | int age,price,noOfFans; 6 | age=15; 7 | price=10; 8 | noOfFans=5; 9 | String op1=age+" "; 10 | String op2=op1+price; 11 | String op3=op2+noOfFans; 12 | // System.out.println(age+" "+price+noOfFans); 13 | System.out.println(op3); 14 | System.out.println((age+price)+" "+noOfFans); 15 | System.out.println(12+""+5*5); 16 | 17 | int size=10,noOfCars=4,noOfTyres=4; 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/review1/E4ShortHandOperators.java: -------------------------------------------------------------------------------- 1 | package review1; 2 | 3 | public class E4ShortHandOperators { 4 | public static void main(String[] args) { 5 | 6 | int age=10; 7 | // age+=20; // adding 20 more to the value of age variable 8 | // age=age+20; 9 | System.out.println(age); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/review1/E5ShortHandOperators.java: -------------------------------------------------------------------------------- 1 | package review1; 2 | 3 | public class E5ShortHandOperators { 4 | public static void main(String[] args) { 5 | // shortcut to format the code Ctrl+Alt+l Cmd+ops+l 6 | int age = 10; 7 | //age *= 2; 8 | age = age * 2; 9 | System.out.println(age); 10 | 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/review1/Notes: -------------------------------------------------------------------------------- 1 | Variables: 2 | Are like boxes/containers which can hold data for us. we can change the data 3 | later on if we want. we can reuse the same variable as many times as we 4 | want. There are 8 basic/primitive data types. 5 | 4 basic data types to store whole numbers. 6 | 1)byte 2) short 3) int 4) long 7 | 2 basic data types to store decimal numbers. 8 | 1)float 2) double 9 | 1 data type 10 | To store characters: 11 | char 12 | To Store true/false 13 | boolean 14 | NonPrimitives: 15 | 1)String 16 | =================================================================== 17 | -------------------------------------------------------------------------------- /src/main/java/review1/T1Variables.java: -------------------------------------------------------------------------------- 1 | package review1; 2 | 3 | public class T1Variables { 4 | // Go to amazon choose any product 5 | //you have to store its 6 | // title price average rating noOfreviews availability 7 | 8 | public static void main(String[] args) { 9 | 10 | String title="Apple AirPods Pro "; 11 | double price=50.5; 12 | int noOfReview=4000; 13 | double avgRating=4.7; 14 | boolean availability=true; 15 | System.out.println(title); 16 | System.out.println(price); 17 | System.out.println(noOfReview); 18 | System.out.println(avgRating); 19 | System.out.println(availability); 20 | // Break till 8:54 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/review10/Animal.java: -------------------------------------------------------------------------------- 1 | package review10; 2 | 3 | public abstract class Animal { 4 | abstract void speak(); 5 | abstract void eat(); 6 | 7 | } 8 | 9 | class Dog extends Animal{ 10 | @Override 11 | void speak() { 12 | System.out.println("Wuff Wuff"); 13 | } 14 | 15 | @Override 16 | void eat() { 17 | System.out.println("Dogs like to eat bones"); 18 | } 19 | } 20 | 21 | class Cat extends Animal{ 22 | @Override 23 | void speak() { 24 | System.out.println("Meow Meow"); 25 | } 26 | 27 | @Override 28 | void eat() { 29 | System.out.println("Cats like to Eat free Fish from Giulia"); 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/review10/Car.java: -------------------------------------------------------------------------------- 1 | package review10; 2 | 3 | public class Car implements WashAble{ 4 | public void drive(){ 5 | System.out.println("driving........"); 6 | } 7 | 8 | @Override 9 | public void wash() { 10 | System.out.println("You can take a car to carWash service"); 11 | } 12 | } 13 | 14 | class Horse implements WashAble{ 15 | 16 | @Override 17 | public void wash() { 18 | System.out.println("Horse can wash themselves "); 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/java/review10/Human.java: -------------------------------------------------------------------------------- 1 | package review10; 2 | 3 | public interface Human { 4 | public static final int MAX_AVG_AGE=100; 5 | public static final String name="John"; 6 | /* public Human(){ 7 | // Constructors are not allowed. 8 | }*/ 9 | 10 | void eat(); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/review10/WashAble.java: -------------------------------------------------------------------------------- 1 | package review10; 2 | 3 | public interface WashAble { 4 | public void wash(); 5 | } 6 | 7 | class WashAbleTester{ 8 | public static void main(String[] args) { 9 | WashAble [] arr={new Car(),new Horse()}; 10 | for (WashAble w:arr){ 11 | w.wash(); 12 | } 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /src/main/java/review11/E1WrapperClasses.java: -------------------------------------------------------------------------------- 1 | package review11; 2 | 3 | import class16.Cat; 4 | 5 | public class E1WrapperClasses { 6 | 7 | public static void main(String[] args) { 8 | 9 | int a=10; 10 | double b=a; 11 | System.out.println(b); 12 | 13 | int f=30; 14 | 15 | Integer g=f; 16 | System.out.println(g); 17 | 18 | double u=30.5; 19 | Double t=u; 20 | System.out.println(u); 21 | 22 | String name="dnfjdnf"; 23 | 24 | Boolean o=false; 25 | boolean s=o; 26 | 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/review11/E2ArrayList.java: -------------------------------------------------------------------------------- 1 | package review11; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class E2ArrayList { 6 | public static void main(String[] args) { 7 | 8 | int [] numbers=new int[10]; 9 | System.out.println(numbers); 10 | 11 | ArrayList nums=new ArrayList<>(10000); 12 | 13 | nums.add(10); 14 | nums.add(15); 15 | nums.add(45); 16 | nums.add(50); 17 | System.out.println(nums); 18 | 19 | nums.remove(new Integer(45)); 20 | System.out.println(nums); 21 | 22 | ArrayList names=new ArrayList<>(); 23 | names.add("Jamil"); 24 | names.add("Artur"); 25 | names.remove("Artur"); 26 | System.out.println(names); 27 | 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/review11/E4ArrayList.java: -------------------------------------------------------------------------------- 1 | package review11; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class E4ArrayList { 6 | public static void main(String[] args) { 7 | 8 | ArrayList fruit=new ArrayList<>(); 9 | fruit.add("Apple"); 10 | fruit.add("Mango"); 11 | fruit.add("Orange"); 12 | fruit.add("Kiwi"); 13 | fruit.add("Banana"); 14 | fruit.add("Cherry"); 15 | 16 | // fruit.clear(); 17 | // fruit.forEach(x-> System.out.println(x)); 18 | fruit.forEach(x->{ 19 | 20 | if(x.contains("a")){ 21 | System.out.println(x); 22 | } 23 | 24 | }); 25 | 26 | // System.out.println(fruit); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/review11/E5ArrayList.java: -------------------------------------------------------------------------------- 1 | package review11; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class E5ArrayList { 6 | public static void main(String[] args) { 7 | 8 | ArrayList fruit=new ArrayList<>(); 9 | fruit.add("Apple"); //0 10 | fruit.add("Mango"); // 1 11 | fruit.add("Orange"); //2 12 | fruit.add("Kiwi"); //3 13 | fruit.add("Banana"); //4 14 | fruit.add("Cherry"); //5 15 | fruit.add("Apple"); //6 16 | 17 | fruit.set(2,"Grapes"); //Its gonna replace elements at index 2 18 | System.out.println(fruit); 19 | fruit.isEmpty(); 20 | 21 | System.out.println(fruit.indexOf("Apple")); 22 | System.out.println(fruit.lastIndexOf("Apple")); 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/review11/E7ArrayList.java: -------------------------------------------------------------------------------- 1 | package review11; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class E7ArrayList { 6 | public static void main(String[] args) { 7 | 8 | ArrayList fruit=new ArrayList<>(); 9 | fruit.add("Apple"); //0 //Milk 10 | fruit.add("Mango"); // 1 //water 11 | fruit.add("Orange"); //2 12 | fruit.add("Kiwi"); //3 13 | fruit.add("Banana"); //4 14 | fruit.add("Cherry"); //5 15 | fruit.add("Apple"); //6 16 | fruit.replaceAll(x->{ 17 | if(x.contains("a")){ 18 | return "water"; 19 | }else { 20 | return x; 21 | } 22 | }); 23 | System.out.println(fruit); 24 | 25 | 26 | 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/review11/E8ArrayList.java: -------------------------------------------------------------------------------- 1 | package review11; 2 | 3 | import java.util.ArrayList; 4 | import java.util.LinkedList; 5 | 6 | public class E8ArrayList { 7 | public static void main(String[] args) { 8 | 9 | LinkedList fruit=new LinkedList<>(); 10 | fruit.add("Apple"); //0 //Milk 11 | fruit.add("Mango"); // 1 //water 12 | fruit.add("Orange"); //2 13 | fruit.add("Kiwi"); //3 14 | fruit.add("Banana"); //4 15 | fruit.add("Cherry"); //5 16 | fruit.add("Apple"); //6 17 | 18 | 19 | 20 | 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/review12/E6Maps.java: -------------------------------------------------------------------------------- 1 | package review12; 2 | 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | public class E6Maps { 8 | public static void main(String[] args) { 9 | Map studentMarksMap=new HashMap<>(); 10 | studentMarksMap.put("Habib",95.5); 11 | studentMarksMap.put("Madina",95.5); 12 | studentMarksMap.put("Arthur",89.5); 13 | studentMarksMap.put("Nelson",97.5); 14 | 15 | studentMarksMap.replaceAll((k,v)->{ 16 | if(k.contains("a")){ 17 | return 10.0; 18 | }else { 19 | return v; 20 | } 21 | }); 22 | System.out.println(studentMarksMap); 23 | 24 | 25 | 26 | } 27 | 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/review12/Human.java: -------------------------------------------------------------------------------- 1 | package review12; 2 | 3 | public interface Human { 4 | 5 | interface Child{ 6 | 7 | } 8 | } 9 | 10 | class Test{ 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/review12/MethodTester.java: -------------------------------------------------------------------------------- 1 | package review12; 2 | 3 | import java.util.Scanner; 4 | 5 | public class MethodTester { 6 | public static void main(String[] args) { 7 | int sum= Methods.add(10,10); 8 | Scanner scanner=new Scanner(System.in); 9 | int num= scanner.nextInt(); 10 | 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/review12/Methods.java: -------------------------------------------------------------------------------- 1 | package review12; 2 | 3 | public class Methods { 4 | public static void main(String[] args) { 5 | 6 | 7 | } 8 | 9 | static int add(int num1,int num2){ 10 | return num1+num2; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/review12/Notes: -------------------------------------------------------------------------------- 1 | Set: 2 | Sets are special set of classes which do not allow duplicate elements. 3 | Set the is the main interface and there are three main classes which implement this 4 | interface. 1)HashSet 2) LinkedHashSet 3) TreeSet. 5 | HashSet: 6 | UpSide: Its fastest of all. 7 | DownSide: It does not remember the insertion order. 8 | LinkedHashSet: 9 | Upside: Maintains the insertion order. 10 | DownSide: Its a little slower than HashSet. 11 | TreeSet: 12 | Upside: Keeps the data in sorted form. 13 | DownSide: Insertion is very very slow. 14 | Maps: 15 | Map is an interface that allows us to store key value pairs. -------------------------------------------------------------------------------- /src/main/java/review13/Account.java: -------------------------------------------------------------------------------- 1 | package review13; 2 | 3 | public class Account { 4 | private double accountBalance; 5 | Account(double accountBalance){ 6 | this.accountBalance=accountBalance; 7 | } 8 | 9 | void transferFunds(double amount)throws InsufficientAccountBalanceException{ 10 | 11 | if(amount>accountBalance){ 12 | throw new InsufficientAccountBalanceException("You don't have enough funds"); 13 | 14 | 15 | } 16 | 17 | } 18 | } 19 | 20 | class AccountTester{ 21 | public static void main(String[] args) { 22 | Account account=new Account(100); 23 | account.transferFunds(12000); 24 | } 25 | } -------------------------------------------------------------------------------- /src/main/java/review13/E1File.java: -------------------------------------------------------------------------------- 1 | package review13; 2 | 3 | import java.util.Scanner; 4 | 5 | public class E1File { 6 | public static void main(String[] args) { 7 | Scanner scanner=new Scanner(System.in); 8 | System.out.println("Please enter your age"); 9 | int age=scanner.nextInt(); 10 | System.out.println(age); 11 | String name="sjbkjs"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/review13/E3Config.java: -------------------------------------------------------------------------------- 1 | package review13; 2 | 3 | import utils.ConfigReader; 4 | 5 | import java.sql.SQLOutput; 6 | 7 | public class E3Config { 8 | public static void main(String[] args) { 9 | 10 | System.out.println(ConfigReader.getProperty("C:\\Users\\Syntax\\IdeaProjects\\JavaSdetBatch17\\src\\Test.properties","name")); 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/review13/E5Excel.java: -------------------------------------------------------------------------------- 1 | package review13; 2 | 3 | import utils.ExcelReader; 4 | 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | public class E5Excel { 9 | public static void main(String[] args) { 10 | 11 | List> data= ExcelReader.readExcelData 12 | ("C:\\Users\\Syntax\\IdeaProjects\\JavaSdetBatch17\\Files\\Employees.xlsx","EmpData"); 13 | System.out.println(data); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/review13/E6Exceptions.java: -------------------------------------------------------------------------------- 1 | package review13; 2 | 3 | import java.io.FileInputStream; 4 | import java.io.FileNotFoundException; 5 | import java.sql.SQLOutput; 6 | 7 | public class E6Exceptions { 8 | public static void main(String[] args) throws FileNotFoundException { 9 | System.out.println(1); 10 | System.out.println(2); 11 | try{ 12 | FileInputStream fileInputStream=new FileInputStream("sjndjs");} 13 | catch (FileNotFoundException f){ 14 | System.out.println("My alternate code as well"); 15 | //System.out.println(f.getMessage()); 16 | // System.out.println(f); 17 | f.printStackTrace(); 18 | } 19 | System.out.println(3); 20 | System.out.println(4); 21 | 22 | 23 | 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/review13/InsufficientAccountBalanceException.java: -------------------------------------------------------------------------------- 1 | package review13; 2 | 3 | /*** 4 | * This exception is thrown when user does not have enough balance 5 | */ 6 | public class InsufficientAccountBalanceException extends RuntimeException{ 7 | public InsufficientAccountBalanceException(String msg){ 8 | super(msg); 9 | } 10 | } 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/review2/E1TypeCasting.java: -------------------------------------------------------------------------------- 1 | package review2; 2 | 3 | public class E1TypeCasting { 4 | public static void main(String[] args) { 5 | 6 | int number=(int)455.555; 7 | System.out.println(number); 8 | float number2=20.100f; 9 | double number3=number2; 10 | System.out.println(number3); 11 | 12 | // boolean bool=(boolean)12.5; error 13 | char c=(char)169; //explicit 14 | System.out.println(c); 15 | // String s=(String)'C'; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/review2/E2IfStatements.java: -------------------------------------------------------------------------------- 1 | package review2; 2 | 3 | public class E2IfStatements { 4 | public static void main(String[] args) { 5 | 6 | boolean condition=10>5; 7 | if(condition){ 8 | System.out.println(1); 9 | }else { 10 | System.out.println(2); 11 | } 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/review2/E3IfElseStatements.java: -------------------------------------------------------------------------------- 1 | package review2; 2 | 3 | public class E3IfElseStatements { 4 | public static void main(String[] args) { 5 | 6 | int age = 18; 7 | if (age >= 18) { 8 | System.out.println("You should work"); 9 | } else { 10 | System.out.println("You should study"); 11 | } 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/review2/E4IfElseScanner.java: -------------------------------------------------------------------------------- 1 | package review2; 2 | 3 | import java.util.Scanner; 4 | 5 | public class E4IfElseScanner { 6 | public static void main(String[] args) { 7 | Scanner scanner=new Scanner(System.in); 8 | System.out.println("Please Enter the price of the item"); 9 | double price=scanner.nextDouble(); 10 | // Break till 8:50 11 | if(price>10000){ 12 | System.out.println("I can't buy this item"); 13 | }else { 14 | System.out.println("lets buy it"); 15 | } 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/review2/E6IfIFDemo.java: -------------------------------------------------------------------------------- 1 | package review2; 2 | 3 | public class E6IfIFDemo { 4 | public static void main(String[] args) { 5 | 6 | int age=61; 7 | if(age==60){ 8 | System.out.println("You get 20% Discount"); 9 | } 10 | 11 | if(age==50){ 12 | System.out.println("You get 15% Discount"); 13 | } 14 | 15 | if(age==40){ 16 | System.out.println("You get 10% Discount"); 17 | } 18 | else { 19 | System.out.println("No Discounts for you. Please try after 10 years"); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/review2/E7CommonScannerIssues.java: -------------------------------------------------------------------------------- 1 | package review2; 2 | 3 | import java.util.Scanner; 4 | 5 | public class E7CommonScannerIssues { 6 | public static void main(String[] args) { 7 | Scanner scanner=new Scanner(System.in); 8 | 9 | System.out.println("What city are you in?"); 10 | String city=scanner.next(); 11 | System.out.println("What is the temperature in that city in fahrenheit?"); 12 | double fahrenheit=scanner.nextDouble(); 13 | double celsius=(fahrenheit-32)*5/9; 14 | System.out.println("The temperature in "+city+" is "+celsius); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/review2/E7NestedIf.java: -------------------------------------------------------------------------------- 1 | package review2; 2 | 3 | public class E7NestedIf { 4 | public static void main(String[] args) { 5 | 6 | String day = "Saturday"; 7 | double accountBalance = 5000; 8 | // == equals() != !equals() 9 | if (day.equals("Sunday")) { 10 | 11 | if (accountBalance > 2000) { 12 | System.out.println("We can buy this"); 13 | } else { 14 | System.out.println("Its too expensive"); 15 | } 16 | 17 | } else if (day.equals("Saturday")) { 18 | System.out.println("Its Saturday lets go for dinner"); 19 | } else { 20 | System.out.println("Lets wait for Sunday"); 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/review2/E8CommonScannerIssues.java: -------------------------------------------------------------------------------- 1 | package review2; 2 | 3 | import java.util.Scanner; 4 | 5 | public class E8CommonScannerIssues { 6 | public static void main(String[] args) { 7 | Scanner scanner=new Scanner(System.in); 8 | 9 | System.out.println("Enter your FullName"); 10 | String fName=scanner.next(); 11 | System.out.println("Please Enter your City"); 12 | scanner.nextLine(); // to consume the enter press 13 | String city= scanner.nextLine(); 14 | System.out.println(fName+" "+city); 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/review3/E1LogicalOperators.java: -------------------------------------------------------------------------------- 1 | package review3; 2 | 3 | public class E1LogicalOperators { 4 | public static void main(String[] args) { 5 | 6 | boolean cond=!true; 7 | System.out.println(!cond); 8 | 9 | boolean flag=true; 10 | boolean box=!flag; 11 | System.out.println(box); 12 | System.out.println(flag); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/review3/E2LogicalOperators.java: -------------------------------------------------------------------------------- 1 | package review3; 2 | 3 | public class E2LogicalOperators { 4 | public static void main(String[] args) { 5 | 6 | 7 | boolean isMeat=false; 8 | boolean isEgg=true; 9 | boolean isFish=false; 10 | boolean milk=false; 11 | boolean vegetables=true; 12 | 13 | boolean isProtein=isEgg||isMeat||isFish; 14 | boolean isGoodDiet=(isEgg||isMeat||isFish) &&milk&&vegetables; 15 | System.out.println(isProtein); 16 | System.out.println(isGoodDiet); 17 | 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/review3/E3Switch.java: -------------------------------------------------------------------------------- 1 | package review3; 2 | 3 | public class E3Switch { 4 | public static void main(String[] args) { 5 | 6 | int age=10; 7 | 8 | switch (age){ 9 | 10 | case 10: 11 | if(age==10||age==20){ 12 | 13 | }else if(age>90){ 14 | 15 | } 16 | break; 17 | case 20: 18 | 19 | 20 | } 21 | 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/review3/E6WhileLoop.java: -------------------------------------------------------------------------------- 1 | package review3; 2 | 3 | public class E6WhileLoop { 4 | public static void main(String[] args) { 5 | 6 | 7 | 8 | int x=1; 9 | while (x<=10){ 10 | System.out.println(x); 11 | x++; 12 | } 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/review3/E7DoWhile.java: -------------------------------------------------------------------------------- 1 | package review3; 2 | 3 | import java.util.Scanner; 4 | 5 | public class E7DoWhile { 6 | public static void main(String[] args) { 7 | 8 | Scanner scanner=new Scanner(System.in); 9 | int x=0; 10 | int sum=0; 11 | do{ 12 | System.out.println("Please Enter the price of item or -1 to terminate"); 13 | x=scanner.nextInt(); 14 | if(x!=-1){ 15 | sum=sum+x;} 16 | System.out.println("Your total bill is "+sum); 17 | }while (x!=-1); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/review3/E8ForLoop.java: -------------------------------------------------------------------------------- 1 | package review3; 2 | 3 | public class E8ForLoop { 4 | public static void main(String[] args) { 5 | 6 | for(int i=0; i<=5;i++){ 7 | System.out.println(i); 8 | } 9 | 10 | for (int i = 100; i >20 ; i--) { 11 | System.out.print(i+" "); 12 | } 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/review3/E9ForLoop.java: -------------------------------------------------------------------------------- 1 | package review3; 2 | 3 | public class E9ForLoop { 4 | public static void main(String[] args) { 5 | 6 | 7 | if (4 > 5){ 8 | System.out.println("hi"); 9 | System.out.println("bye"); 10 | } 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/review3/Notes: -------------------------------------------------------------------------------- 1 | Logical operators: 2 | Logical operators help us combine multiple boolean values. 3 | There are three main logical operators in java. 4 | 1) Not(!) 2) OR (||) AND (&&) 5 | 1) NOT(!) 6 | boolean cond=true; 7 | sout"!cond" 8 | 2)OR(||) 9 | Logical OR help us combine 10 | -------------------------------------------------------------------------------- /src/main/java/review3/T1LogicalOperators.java: -------------------------------------------------------------------------------- 1 | package review3; 2 | 3 | import java.util.Scanner; 4 | 5 | public class T1LogicalOperators { 6 | public static void main(String[] args) { 7 | Scanner scanner=new Scanner(System.in); 8 | System.out.println("Please enter your first boolean value true/false"); 9 | boolean var1=scanner.nextBoolean(); 10 | System.out.println("Please enter your second boolean value true/false"); 11 | boolean var2=scanner.nextBoolean(); 12 | 13 | if(var1&&var2){ 14 | System.out.println("Both values are true"); 15 | }else { 16 | System.out.println("Both values are not true"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/review3/T2WhileLoop.java: -------------------------------------------------------------------------------- 1 | package review3; 2 | 3 | public class T2WhileLoop { 4 | public static void main(String[] args) { 5 | // 62 63 66 67 68 69 70 6 | int start = 62; 7 | int end = 70; 8 | 9 | while (start <= end) { 10 | if (start != 64 && start != 65) { 11 | System.out.print(start + " "); 12 | 13 | } 14 | start++; 15 | 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/review4/E1NestedLoop.java: -------------------------------------------------------------------------------- 1 | package review4; 2 | 3 | public class E1NestedLoop { 4 | public static void main(String[] args) { 5 | for(int h=0;h<24;h++){ 6 | for (int m = 0; m < 60; m++) { 7 | 8 | for (int s = 0; s <60 ; s++) { 9 | if(s<10 &&m<10){ 10 | System.out.println(h+":0"+m+":0"+s); 11 | }else if(s>=10 &&m<10){ 12 | System.out.println(h+":0"+m+":"+s); 13 | }else{ 14 | System.out.println(h+":"+m+":"+s); 15 | } 16 | 17 | } 18 | } 19 | 20 | }} 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/review4/E2NestedLoop.java: -------------------------------------------------------------------------------- 1 | package review4; 2 | 3 | public class E2NestedLoop { 4 | public static void main(String[] args) { 5 | 6 | for (int i = 0; i < 5; i++) { 7 | System.out.println("Hello"); 8 | for (int j = 0; j < 3; j++) { 9 | System.out.println("Happy Birthday Fahim"); 10 | } 11 | } 12 | 13 | 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/review4/E3NestedLoop.java: -------------------------------------------------------------------------------- 1 | package review4; 2 | 3 | public class E3NestedLoop { 4 | public static void main(String[] args) { 5 | 6 | for (int i = 0; i < 5; i++) { 7 | 8 | for (int j = i; j <= 3; j++) { 9 | System.out.println(i+" "+j); 10 | } 11 | } 12 | 13 | 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/review4/E4NestedLoop.java: -------------------------------------------------------------------------------- 1 | package review4; 2 | 3 | public class E4NestedLoop { 4 | public static void main(String[] args) { 5 | 6 | /* 7 | ##### 8 | ##### 9 | ##### 10 | ##### 11 | */ 12 | 13 | for (int i = 0; i < 4; i++) { 14 | for (int j = 0; j <5 ; j++) { 15 | System.out.print("#"); 16 | } 17 | System.out.println(); 18 | } 19 | 20 | 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/review4/E5NestedLoop.java: -------------------------------------------------------------------------------- 1 | package review4; 2 | 3 | public class E5NestedLoop { 4 | public static void main(String[] args) { 5 | /* 6 | * 7 | * * 8 | * * * 9 | * * * * 10 | * * * 11 | * * 12 | * 13 | 14 | */ 15 | // Break till 8:53 16 | for (int i = 1; i <= 4; i++) { 17 | for (int j = 0; j < i; j++) { 18 | System.out.print("*"); 19 | } 20 | System.out.println(); 21 | } 22 | 23 | for (int j = 1; j <= 3; j++) { 24 | for (int i = 0; i < 4 - j; i++) { //3 25 | System.out.print("*"); 26 | } 27 | System.out.println(); 28 | } 29 | 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/review4/E6Arrays.java: -------------------------------------------------------------------------------- 1 | package review4; 2 | 3 | public class E6Arrays { 4 | public static void main(String[] args) { 5 | 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/review4/E7Arrays.java: -------------------------------------------------------------------------------- 1 | package review4; 2 | 3 | public class E7Arrays { 4 | public static void main(String[] args) { 5 | 6 | int [] salaries={120000,150000,200000}; 7 | System.out.println(salaries[1]); 8 | //updating the value at index 1 9 | salaries[1]=160000; 10 | System.out.println(salaries[1]); 11 | // salaries[3]=1450000; // outOfBound 12 | // System.out.println(salaries[3]); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/review4/E8Arrays.java: -------------------------------------------------------------------------------- 1 | package review4; 2 | 3 | import java.util.Arrays; 4 | 5 | public class E8Arrays { 6 | public static void main(String[] args) { 7 | 8 | int [] salaries={120000,150000,200000}; 9 | 10 | /* for (int i = 0; i < salaries.length; i++) { 11 | System.out.println(salaries[i]); 12 | }*/ 13 | System.out.println(salaries.length); 14 | System.out.println(Arrays.toString(salaries)); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/review4/E9Arrays.java: -------------------------------------------------------------------------------- 1 | package review4; 2 | 3 | import java.util.Arrays; 4 | import java.util.Scanner; 5 | 6 | public class E9Arrays { 7 | public static void main(String[] args) { 8 | 9 | Scanner scanner=new Scanner(System.in); 10 | System.out.println("Please Enter the size of the array"); 11 | int size=scanner.nextInt(); 12 | int[] numbers =new int[size]; 13 | 14 | for (int i = 0; i < numbers.length; i++) { 15 | System.out.println("Please Enter the number "+i); 16 | numbers[i]=scanner.nextInt(); 17 | } 18 | System.out.println("You entered these numbers"); 19 | System.out.println(Arrays.toString(numbers)); 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/review4/Repl67.java: -------------------------------------------------------------------------------- 1 | package review4; 2 | /* 3 | 1 2 3 4 5 6 7 8 9 10 4 | 5 | 2 4 6 8 10 12 14 16 18 20 6 | 7 | 3 6 9 12 15 18 21 24 27 30 8 | 9 | 4 8 12 16 20 24 28 32 36 40 10 | 11 | 5 10 15 20 25 30 35 40 45 50 12 | */ 13 | public class Repl67 { 14 | public static void main(String[] args) { 15 | 16 | for (int i = 1; i <=5 ; i++) { 17 | 18 | for (int j = 1; j <=10 ; j++) { 19 | System.out.print(i*j+" "); 20 | } 21 | System.out.println(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/review5/AnotherReview.java: -------------------------------------------------------------------------------- 1 | package review5; 2 | 3 | public class AnotherReview { 4 | 5 | public static void main(String[] args) { 6 | 7 | double[] price={1.99, 12.09, 1, 4.50}; 8 | // [0] [1] [2] [3] 9 | 10 | for(double number: price){ 11 | 12 | System.out.println(number); 13 | } 14 | 15 | // regular for loop 16 | 17 | for(int i=0; imaking a call to the CURRENT class constructor 16 | this.age=age; // this. ->accessing CURRENT class instance variables 17 | } 18 | 19 | public static void main(String[] args) { 20 | Superheroes hero1=new Superheroes("Superman", "Fly"); 21 | 22 | Superheroes hero2=new Superheroes("Batman", "Money",27); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/review8/Car.java: -------------------------------------------------------------------------------- 1 | package review8; 2 | 3 | public class Car { 4 | private String make; 5 | private String model; 6 | 7 | public Car(String make,String model) { 8 | this(); 9 | this.make=make; 10 | this.model=model; 11 | 12 | } 13 | 14 | public Car(String make) { 15 | this(); 16 | this.make=make; 17 | 18 | } 19 | public Car() { 20 | System.out.println(1); 21 | System.out.println(2); 22 | System.out.println(3); 23 | System.out.println(4); 24 | } 25 | 26 | public static void main(String[] args) { 27 | new Car("Toyta"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/review8/E1LocalVariables.java: -------------------------------------------------------------------------------- 1 | package review8; 2 | 3 | public class E1LocalVariables { 4 | 5 | public static void main(String[] args) { 6 | // System.out.println(country); 7 | String country="Uganda"; 8 | { 9 | int age=10; 10 | System.out.println(country); 11 | } 12 | 13 | if(10>5){ 14 | System.out.println(country); 15 | String name="Wanda"; 16 | } 17 | System.out.println(country); 18 | // System.out.println(name); 19 | 20 | // System.out.println(age); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/review8/E2InstanceVar.java: -------------------------------------------------------------------------------- 1 | package review8; 2 | 3 | public class E2InstanceVar { 4 | 5 | String name; 6 | 7 | void printName(){ 8 | System.out.println(name); 9 | } 10 | 11 | void PrintInformation(){ 12 | System.out.println(name); 13 | } 14 | 15 | static void printInfo(){ 16 | //System.out.println(name); 17 | } 18 | 19 | public static void main(String[] args) { 20 | 21 | 22 | E2InstanceVar.printInfo(); 23 | 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/review8/E3StaticVar.java: -------------------------------------------------------------------------------- 1 | package review8; 2 | 3 | public class E3StaticVar { 4 | public static final String country="USA"; 5 | 6 | void printName(){ 7 | System.out.println(country); 8 | } 9 | 10 | static void printCountry(){ 11 | System.out.println(country); 12 | } 13 | 14 | public static void main(String[] args) { 15 | System.out.println(country); 16 | } 17 | } 18 | 19 | class StaticTester{ 20 | public static void main(String[] args) { 21 | System.out.println(E3StaticVar.country); 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/review9/Animal.java: -------------------------------------------------------------------------------- 1 | package review9; 2 | 3 | public class Animal { 4 | void sleep(){ 5 | System.out.println("Animals sleep"); 6 | } 7 | void speak(){ 8 | System.out.println("Animals speak"); 9 | } 10 | } 11 | class Dog extends Animal{ 12 | 13 | @Override 14 | void speak() { 15 | System.out.println("Wuff Wuff"); 16 | } 17 | } 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/review9/AnimalTester.java: -------------------------------------------------------------------------------- 1 | package review9; 2 | 3 | public class AnimalTester { 4 | public static void main(String[] args) { 5 | Dog d=new Dog(); 6 | d.speak(); 7 | d.sleep(); 8 | 9 | Animal a=new Animal(); 10 | a.speak(); 11 | 12 | Animal c=new Dog(); 13 | c.speak(); 14 | 15 | int e=(int)10.5; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/review9/Calculator.java: -------------------------------------------------------------------------------- 1 | package review9; 2 | 3 | public class Calculator { 4 | 5 | void add(int a,int b){ 6 | System.out.println(a+b); 7 | } 8 | 9 | int add(int ... arr){ 10 | int sum=0; 11 | for (int a:arr){ 12 | sum+=a; 13 | } 14 | return sum; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/review9/CalculatorTester.java: -------------------------------------------------------------------------------- 1 | package review9; 2 | 3 | import org.checkerframework.checker.units.qual.C; 4 | 5 | public class CalculatorTester { 6 | public static void main(String[] args) { 7 | Calculator c=new Calculator(); 8 | // int s= c.add(10,20); 9 | int result=c.add(10,20,30); 10 | System.out.println(c.add(10,20,30,40,50)); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/review9/Main2.java: -------------------------------------------------------------------------------- 1 | package review9; 2 | 3 | class Main2 { 4 | public static void main(String[] args) { 5 | 6 | 7 | 8 | } 9 | 10 | } 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main/java/review9/ParentTester.java: -------------------------------------------------------------------------------- 1 | package review9; 2 | 3 | public class ParentTester { 4 | public static void main(String[] args) { 5 | 6 | Child c=new Child(); 7 | c.test(); 8 | //c.methodTest(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/review9/PrinterTester.java: -------------------------------------------------------------------------------- 1 | package review9; 2 | 3 | import java.util.Scanner; 4 | 5 | public class PrinterTester { 6 | public static void main(String[] args) { 7 | /* Printer p=new Printer(); 8 | p.print(20); 9 | p.print(10,20,20,45,50); 10 | p.print(10,20,50); 11 | System.out.println(); 12 | 13 | System.out.println(Math.abs(15)); 14 | Scanner scanner=new Scanner(System.in); 15 | scanner.nextByte(); 16 | scanner.nextByte(2);*/ 17 | String str = String.valueOf(100); 18 | System.out.println(str); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/utils/Constants.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | public class Constants { 4 | public static final String CONFIG_FILE_PATH=System.getProperty("user.dir") + "\\Files\\Config.properties"; 5 | public static final String EXCEL_FILE_PATH= System.getProperty("user.dir") + "\\Files\\Employees.xlsx"; 6 | } 7 | --------------------------------------------------------------------------------