├── .gitignore
├── .idea
├── .gitignore
├── encodings.xml
├── misc.xml
├── uiDesigner.xml
└── vcs.xml
├── Files
├── Batch18.xlsx
└── Config.properties
├── pom.xml
└── src
└── main
└── java
└── org
├── class1
├── E10Variables.java
├── E1Print.java
├── E2PrintStatement.java
├── E3Variables.java
├── E4Variables.java
├── E5Variables.java
├── E6Variables.java
├── E7Variables.java
├── E8Variables.java
├── E9VarRules.java
├── Notes.txt
├── T1Programmer.java
└── T2SyntaxProgrammer.java
├── class10
├── Car.java
├── CarTester.java
├── Dog.java
├── DogTester.java
├── E1ClassesObjects.java
├── Notes.txt
├── Person.java
├── PersonTester.java
└── Phone.java
├── class11
├── E10StringDemo.java
├── E11StringDemo.java
├── E1StringDemo.java
├── E2StringDemo.java
├── E3StringDemo.java
├── E4StringDemo.java
├── E5StringDemo.java
├── E6StringDemo.java
├── E7StringDemo.java
├── E8StringDemo.java
├── E9StringDemo.java
├── Notes.txt
├── T1String.java
├── T2String.java
├── T3String.java
└── T4String.java
├── class12
├── E1StringDemo.java
├── E2StringDemo.java
├── E3StringBuilder.java
├── E4Methods.java
├── Math.java
├── MathTester.java
├── Notes.txt
├── StringVsStringBuilder.java
├── T1String.java
├── T2String.java
├── T3String.java
├── T4String.java
├── T5String.java
├── T6String.java
└── T7String.java
├── class13
├── AccountTester2.java
├── E1Methods.java
├── Math.java
├── MathTester.java
├── Notes.txt
├── Printer.java
├── PrinterTester.java
├── Task1.java
├── Task2.java
└── Task3.java
├── class14
├── Account.java
├── AccountTester.java
├── Cat.java
├── CatTester.java
├── Dog.java
├── E1LocalVar.java
├── Horse.java
├── HorseTester.java
├── MathDemo.java
├── Notes.txt
├── Person.java
├── PersonTester.java
├── T1.java
└── T2.java
├── class15
├── Ambient-music-free.mp3
├── Book.java
├── Cat.java
├── CatTester.java
├── Demo.java
├── DemoTester.java
├── Dog.java
├── DogTester.java
├── E1AudioPlayer.java
├── E1BrowserDemo.java
├── Notes.txt
├── Person.java
├── PersonTester.java
├── Student.java
├── StudentTester.java
├── T1.java
├── T1Tester.java
└── Teacher.java
├── class16
├── Animal.java
├── Animal2.java
├── AnimalTester.java
├── Cat.java
├── Dog.java
├── E.java
├── MultilevelTester.java
├── Notes.txt
├── Person.java
├── Teacher.java
├── TeacherTester.java
└── X.java
├── class17
├── AnimalTester.java
├── Dog.java
├── E1MethodOverloading.java
├── Notes.txt
└── Parent.java
├── class18
├── Animal.java
├── AnimalTester.java
├── CreditCard.java
├── Degree.java
├── FinalDemo.java
├── Notes.txt
├── Parent.java
├── Person.java
├── PersonTester.java
├── Printer.java
├── StringBuilderDemo.java
└── StringDemo.java
├── class19
├── Animal.java
├── AnimalTester.java
├── BrowserTester.java
├── Chrome.java
├── Computer.java
├── ComputerTester.java
├── E1ObjectTypeCasting.java
├── E2Poly.java
├── E3Poly.java
├── E4Poly.java
├── E5Poly.java
├── Notes.txt
├── StTester.java
└── Student.java
├── class2
├── E10Quiz.java
├── E11VarUpdate.java
├── E12VarUpdate.java
├── E13ShortHandOp.java
├── E14ShortHandOp.java
├── E15ShortHandOp.java
├── E16RelationalOp.java
├── E17RelationalOp.java
├── E18RelationalOp.java
├── E19Vars.java
├── E2Print.java
├── E3ArithmeticOp.java
├── E3UpdateVar.java
├── E4Concat.java
├── E5Concat.java
├── E6Concat.java
├── E7Division.java
├── E8Quiz.java
├── E9Quiz.java
├── Notes.txt
├── T1Variables.java
├── T2.java
├── T3.java
└── T4.java
├── class20
├── Computer.java
└── Store.java
├── class21
├── Animal.java
├── AnimalTester.java
├── Drawing.java
├── ExcelFile.java
├── File.java
├── FileTester.java
├── Notes.txt
└── ReadData.java
├── class22
├── BankAccount.java
├── BankAccountTester.java
├── Calculator.java
├── E1ArrayList.java
├── E1CF.java
├── E2ArrayList.java
├── E3ArrayList.java
├── E4ArrayList.java
├── E5ArrayList.java
├── E6ArrayList.java
├── EmployeeTester.java
├── Human.java
├── MathTester.java
├── Notes.txt
├── T1.java
├── T2.java
├── T3.java
├── T4.java
└── WebDriver.java
├── class23
├── E1LinkedList.java
├── E2LinkedList.java
├── E3Sets.java
├── E4Sets.java
├── E5Sets.java
├── E6Sets.java
├── E7Sets.java
├── E8Collection.java
├── Notes
├── Student.java
├── T1.java
├── T2.java
├── T3.java
└── T4.java
├── class24
├── E1Maps.java
├── E2Maps.java
├── E3Maps.java
├── E4Maps.java
├── E5Maps.java
├── E6Maps.java
├── E7Maps.java
├── E8Maps.java
├── E9AnaGram.java
├── E9Maps.java
├── Notes
├── Person.java
├── T1.java
├── Task2.java
└── Task3.java
├── class25
├── E1FileHandling.java
├── E2FileHandling.java
├── E3Selenium.java
├── E4ExcelFile.java
├── E5ExcelFile.java
├── E6NestedData.java
├── E7NestedData.java
├── E8ExcelFile.java
└── Notes
├── class26
├── E1ExcelFile.java
├── E2ExcelFile.java
├── E3ExcelFile.java
├── E4ExcelFile.java
├── E5Exception.java
├── E5HRMSTester.java
├── E6Exception.java
├── E7Exception.java
└── Notes.txt
├── class27
├── BankAccount.java
├── BankTester.java
├── E1Exception.java
├── E2Exception.java
├── E3Exception.java
├── E4Exceptions.java
├── E5Exception.java
├── E6Exception.java
├── E7Exception.java
├── E8Exception.java
├── FileReader.java
├── InsufficientFundsException.java
└── Notes.txt
├── class3
├── E10IfElseStatement.java
├── E11ElseIf.java
├── E12IfElse.java
├── E1ElseIfQuiz.java
├── E1TypeCasting.java
├── E2TypeCasting.java
├── E3TypeCasting.java
├── E4TypeCastingQuiz.java
├── E5IfElseStatements.java
├── E6IfElseStatement.java
├── E7IfElseStatement.java
├── E8IfElseStatement.java
├── E9RelationalOperator.java
├── Notes.txt
├── T1DoubleComparison.java
├── T2TempCheck.java
├── T3.java
├── T4.java
├── T5.java
├── T6.java
├── T7.java
├── T8.java
└── T9.java
├── class4
├── E1NestedIfConditions.java
├── E2NestedIfConditions.java
├── E3Scanner.java
├── E4Scanner.java
├── E5Scanner.java
├── E6Scanner.java
├── E7Scanner.java
├── Notes
├── ScannerIssues.java
├── T1.java
├── T2.java
├── T3.java
├── T4.java
└── T5.java
├── class5
├── E1LogicalOperators.java
├── E2LogicalOperators.java
├── E3LogicalOperators.java
├── E4LogicalOperators.java
├── E5LogicalOperators.java
├── E6LogicalAND.java
├── E7Switch.java
├── E8Switch.java
├── Notes
├── StringMethodDemo.java
├── T1.java
├── T2.java
├── T3.java
├── T4.java
├── T5.java
└── T6.java
├── class6
├── E10ForLoop.java
├── E11ForLoop.java
├── E12ScannerAndLoop.java
├── E1loop.java
├── E2Loop.java
├── E3Loop.java
├── E4loop.java
├── E5Loop.java
├── E6Loop.java
├── E7Loop.java
├── E8Loop.java
├── E9ForLoop.java
├── T1.java
├── T2.java
├── T3.java
├── T4.java
├── T5.java
├── T6.java
├── T7.java
├── T8.java
└── notes.txt
├── class7
├── E10Arrays.java
├── E11Arrays.java
├── E12Arrays.java
├── E13Arrays.java
├── E1NestedLoops.java
├── E2NestedLoops.java
├── E3NestedLoops.java
├── E4NestedLoops.java
├── E5NestedLoops.java
├── E6NestedLoops.java
├── E7Arrays.java
├── E8Arrays.java
├── E9Arrays.java
└── Note
├── class8
├── E1Arrays.java
├── E2Arrays.java
├── E3Continue.java
├── E4Continue.java
├── E5ScannerAndArray.java
├── E6EnhancedForLoop.java
├── E7Loops.java
├── Notes.txt
├── T1.java
├── T2.java
├── T3.java
└── T4.java
├── class9
├── E1Array.java
├── E2Arrays.java
├── E3Arrays.java
├── E4Arrays.java
├── E5Arrays.java
├── Notes.txt
├── T1.java
├── T2.java
├── T3.java
├── T4.java
└── T5.java
├── interview
├── Main.java
├── Notes
├── PrintNumbers.java
├── Q20.java
└── Test.java
├── project2
├── Max.java
├── Q1.java
├── Q2.java
├── Q3.java
├── Q4.java
├── Q5.java
├── Q5WithMap.java
├── Q6.java
├── Q7.java
└── Q9.java
├── review1
├── E1Variables.java
├── E2Variables.java
├── E3StringConcat.java
├── E4StringConcat.java
├── E5Arithmetic.java
├── E6ShortHand.java
└── Note.txt
├── review10
├── BankAccount.java
├── BankTester.java
├── Dog.java
├── E1ArrayList.java
├── E2ArrayList.java
└── Notes
├── review11
├── E1ArrayListVsLinkedList.java
├── E2Maps.java
├── E3Maps.java
├── E4Stream.java
├── E5Files.java
├── E6Files.java
├── E7Files.java
├── Notes
└── Quiz.java
├── review12
├── BrainNotFound.java
├── E1Exception.java
├── E2Exception.java
├── E3Exception.java
├── E4Exception.java
├── Notes.txt
└── Tester.java
├── review2
├── AnotherNestedIf.java
├── ElseBlock.java
├── ElseIfBlock.java
├── NestedIf.java
├── Recap.java
└── RelationalOperators.java
├── review3
├── LogicalAnd.java
├── LogicalNot.java
├── LogicalOr.java
├── ScannerExample.java
├── SwitchAgain.java
├── SwitchAndScanner.java
└── SwitchStatement.java
├── review4
├── DoWhileLoop.java
├── ForLoop.java
├── NestedLoop.java
└── WhileLoop.java
├── review5
├── E10ArraysScanner.java
├── E1Arrays.java
├── E2Arrays.java
├── E3Arrays.java
├── E4Arrays.java
├── E5Arrays.java
├── E6Arrays.java
├── E7Arrays.java
├── E8D2Array.java
├── E9D2Array.java
└── Note.tct
├── review6
├── Crow.java
├── E10StringDemo.java
├── E11StringDemo.java
├── E12StringDemo.java
├── E1StringDemo.java
├── E2StringDemo.java
├── E3StringDemo.java
├── E4StringDemo.java
├── E5StringDemo.java
├── E6StringDemo.java
├── E7StringDemo.java
├── E8StringDemo.java
├── E9StringDemo.java
├── Notes.txt
└── Person.java
├── review7
├── Bird.java
├── Cat.java
├── Dog.java
├── DogTester.java
├── E1.java
├── E1Method.java
├── E2TypesOfVariables.java
├── MathTester.java
├── Notes.txt
├── Printer.java
└── Tester.java
├── review8
├── Doctor.java
├── EmergencyRoom.java
├── Hospital.java
├── Sport.java
└── Stadium.java
├── review8_1
└── Orthodontist.java
├── review9
├── Animal.java
├── CarTester.java
├── Notes.txt
├── PolyTester.java
└── WashAble.java
└── utils
├── ConfigReader.java
├── Constants.java
├── ExcelReader.java
└── Test.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/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Files/Batch18.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SyntaxTechnologies/SDETJavaBatch18/e16838663b9cb702655b0e0ed2f3310b5ab149ef/Files/Batch18.xlsx
--------------------------------------------------------------------------------
/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
5 |
--------------------------------------------------------------------------------
/src/main/java/org/class1/E10Variables.java:
--------------------------------------------------------------------------------
1 | package org.class1;
2 |
3 | public class E10Variables {
4 | public static void main(String[] args) {
5 | // int age,salary,familyMember;
6 | int age=10,salary=10,familyMember=10;
7 | System.out.println(salary);
8 |
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/class1/E1Print.java:
--------------------------------------------------------------------------------
1 | package org.class1;
2 |
3 | public class E1Print {
4 |
5 | }
6 |
--------------------------------------------------------------------------------
/src/main/java/org/class1/E2PrintStatement.java:
--------------------------------------------------------------------------------
1 | package org.class1;
2 |
3 | public class E2PrintStatement {
4 | //Every word of the class name should be capital
5 | // It makes it easier to read the long names
6 | //this convention in java is called camel case
7 | public static void main(String[] args) {
8 | System.out.println("Asghar");
9 | }
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/org/class1/E3Variables.java:
--------------------------------------------------------------------------------
1 | package org.class1;
2 |
3 | public class E3Variables {
4 |
5 | /*
6 | A variable is like a container in our real life
7 | we can store things inside it and we can also replace
8 | them if we want
9 | */
10 |
11 | // every line must end with semicolon in java
12 | public static void main(String[] args) {
13 | String box1="Asghar";
14 | System.out.println(box1);
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/class1/E4Variables.java:
--------------------------------------------------------------------------------
1 | package org.class1;
2 |
3 | public class E4Variables {
4 |
5 | public static void main(String[] args) {
6 | //create a box of type String
7 | //store the name of your city
8 | //print it
9 | String city="Lahore";
10 | System.out.println(city);
11 |
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/class1/E5Variables.java:
--------------------------------------------------------------------------------
1 | package org.class1;
2 |
3 | public class E5Variables {
4 |
5 | public static void main(String[] args) {
6 |
7 | byte num1=127;
8 | short num2=1000;
9 | int num3=1224545212;
10 | long num4=4545121154551212L;
11 |
12 | System.out.println(num1);
13 | System.out.println(num2);
14 | System.out.println(num3);
15 | System.out.println(num1);
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/org/class1/E6Variables.java:
--------------------------------------------------------------------------------
1 | package org.class1;
2 |
3 | public class E6Variables {
4 | public static void main(String[] args) {
5 |
6 | float box1=15.52F;
7 | double box2=45286425.2154545451212;
8 | System.out.println(box1);
9 |
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/org/class1/E7Variables.java:
--------------------------------------------------------------------------------
1 | package org.class1;
2 |
3 | public class E7Variables {
4 |
5 | public static void main(String[] args) {
6 |
7 | boolean isRaining=true;
8 | System.out.println(isRaining);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/class1/E8Variables.java:
--------------------------------------------------------------------------------
1 | package org.class1;
2 |
3 | public class E8Variables {
4 | public static void main(String[] args) {
5 |
6 | char gender='M';
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/org/class1/E9VarRules.java:
--------------------------------------------------------------------------------
1 | package org.class1;
2 |
3 | public class E9VarRules {
4 | public static void main(String[] args) {
5 | /*
6 | 1000000000 => 10E9 10x10^9
7 | 123456789 1.23E7
8 | */
9 | // box1=10;// missing the data type
10 | // int num1="10"; only whole numbers are allowed
11 | // int =10; name of the box is missing
12 | // int num1=10;
13 | // int num1=20; duplicate var names not allowed in same class
14 | int a=10;
15 | a=20; // replace the 10 with 20
16 | System.out.println(a);
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/org/class1/T1Programmer.java:
--------------------------------------------------------------------------------
1 | package org.class1;
2 |
3 | public class T1Programmer {
4 | public static void main(String[] args) {
5 | // THis is my third java program
6 | String whoMI="I am a Java Programmer";
7 | System.out.println(whoMI);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/org/class1/T2SyntaxProgrammer.java:
--------------------------------------------------------------------------------
1 | package org.class1;
2 |
3 | public class T2SyntaxProgrammer {
4 | public static void main(String[] args) {
5 | System.out.println("I am a Java Programmer. I study at Syntax.");
6 | System.out.println("I am trying love Java!");
7 | System.out.println("!!!");
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/org/class10/Car.java:
--------------------------------------------------------------------------------
1 | package org.class10;
2 |
3 | public class Car {
4 | /*
5 | Attributes/fields/properties/states
6 | */
7 | String make;
8 | String model;
9 | int price;
10 | String color;
11 |
12 | /*
13 | methods/function/behaviours
14 | */
15 | void honk(){
16 | System.out.println("ppepepep Batch 18");
17 | }
18 | void ApplyBrake(){
19 | System.out.println("Stopping........");
20 | }
21 |
22 | void drive(){
23 | System.out.println("driving........");
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/org/class10/CarTester.java:
--------------------------------------------------------------------------------
1 | package org.class10;
2 |
3 | public class CarTester {
4 | public static void main(String[] args) {
5 |
6 | //Create an object from the class
7 | Car bmw=new Car();
8 | bmw.model="I7";
9 | bmw.color="Blue";
10 | bmw.make="BMW";
11 | bmw.price=120000;
12 | bmw.drive();
13 | bmw.honk();
14 | bmw.ApplyBrake();
15 | // Break till 8:54
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/class10/Dog.java:
--------------------------------------------------------------------------------
1 | package org.class10;
2 |
3 | public class Dog {
4 | String name;
5 | String color;
6 | String breed;
7 | int age;
8 | double weight;
9 |
10 | void bark(){
11 | System.out.println("Wau Wau....");
12 | }
13 |
14 | void sleep(){
15 | System.out.println("ZZZzzzzZZZZ.....");
16 | }
17 |
18 | void eat(){
19 | System.out.println("Eating meat.......");
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/class10/E1ClassesObjects.java:
--------------------------------------------------------------------------------
1 | package org.class10;
2 |
3 | import java.util.Scanner;
4 |
5 | public class E1ClassesObjects {
6 | public static void main(String[] args) {
7 | Scanner scanner=new Scanner(System.in);
8 | scanner.nextInt();
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/class10/Notes.txt:
--------------------------------------------------------------------------------
1 | Object Oriented Programming(OOPs):
2 | OOPs is just a style of programming. Just a way of
3 | writing code that helps us write large amounts
4 | of code easily. It helps us manage and change large
5 | amounts of code. There are other ways as well
6 | as functional programming and procedural programming.
7 | Pillars of OOPs:
8 | There are four main pillars of OOPs.
9 | 1) Inheritance
10 | 2) Polymorphism
11 | 3) Abstraction
12 | 4) Encapsulation
13 | Classes and Objects:
14 | A class is a template/design/map/idea/blueprint
15 | from which objects are created.
16 |
17 | Create a class Person
18 | create some fields 3-5
19 | 3-5 methods
20 |
21 |
--------------------------------------------------------------------------------
/src/main/java/org/class10/Person.java:
--------------------------------------------------------------------------------
1 | package org.class10;
2 |
3 | public class Person {
4 |
5 | String name;
6 | int age;
7 | double weight;
8 | char gender;
9 |
10 | void eat(){
11 | System.out.println("Eating.......");
12 | }
13 | void sleep(){
14 | System.out.println("Sleeping........");
15 | }
16 | void run(){
17 | System.out.println("Running ");
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/org/class10/PersonTester.java:
--------------------------------------------------------------------------------
1 | package org.class10;
2 |
3 | public class PersonTester {
4 | public static void main(String[] args) {
5 |
6 | Person p1=new Person();
7 | p1.name="Adams";
8 | p1.age=23;
9 | p1.weight=170;
10 | p1.gender='M';
11 | System.out.println(p1.name);
12 | System.out.println(p1.age);
13 | System.out.println(p1.weight);
14 | System.out.println(p1.gender);
15 | p1.eat();
16 | p1.sleep();
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/org/class11/E10StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.class11;
2 |
3 | public class E10StringDemo {
4 | public static void main(String[] args) {
5 |
6 | String str="Batch 18 is Good";
7 | System.out.println(str.replace("Good","Great"));
8 | System.out.println(str.replace("18","17"));
9 | System.out.println(str.replace("o","R"));
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/org/class11/E2StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.class11;
2 |
3 | public class E2StringDemo {
4 | public static void main(String[] args) {
5 | // Creating an object of String class
6 | String str="dfdfd";
7 | String str2= new String("Batch 18");
8 | System.out.println(str.length());
9 | System.out.println(str2.length());
10 |
11 | boolean isEmpty= str.isEmpty();
12 | System.out.println(isEmpty);
13 |
14 |
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/org/class11/E3StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.class11;
2 |
3 | public class E3StringDemo {
4 | public static void main(String[] args) {
5 |
6 | String str=" Ja va ";
7 | System.out.println(str);
8 | System.out.println(str.trim());
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/class11/E4StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.class11;
2 |
3 | public class E4StringDemo {
4 | public static void main(String[] args) {
5 |
6 | String str="Now i Love Java Java is great";
7 | System.out.println(str.startsWith("Now"));
8 | System.out.println(str.endsWith("Java"));
9 | System.out.println(str.contains("Python"));
10 |
11 |
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/class11/E5StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.class11;
2 |
3 | public class E5StringDemo {
4 | public static void main(String[] args) {
5 |
6 | String str="JAVA";
7 | System.out.println(str.equals("Java"));
8 | System.out.println(str.equalsIgnoreCase("java"));
9 | // Break till 11:48
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/org/class11/E6StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.class11;
2 |
3 | public class E6StringDemo {
4 | public static void main(String[] args) {
5 |
6 | String str="Java is Fun";
7 | char c= str.charAt(5);
8 | System.out.println(c);
9 |
10 | for (int i = 0; i < str.length(); i++) {
11 | System.out.println(str.charAt(i));
12 | }
13 |
14 |
15 |
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/class11/E7StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.class11;
2 |
3 | public class E7StringDemo {
4 | public static void main(String[] args) {
5 |
6 | String str=" HELLO "; //hello
7 | System.out.println(str.trim().length());
8 | System.out.println(str.trim().toLowerCase().equals("hello"));
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/class11/E8StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.class11;
2 |
3 | public class E8StringDemo {
4 | public static void main(String[] args) {
5 |
6 | String str="Today is Saturday";
7 | // print the all the index of letter a from above string
8 | System.out.println(str.indexOf('T'));
9 | System.out.println(str.indexOf('o'));
10 | System.out.println(str.indexOf('S'));
11 | System.out.println(str.indexOf('a'));
12 | System.out.println(str.indexOf('Z'));
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/class11/E9StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.class11;
2 |
3 | public class E9StringDemo {
4 | public static void main(String[] args) {
5 |
6 | String str="Today is Saturday";
7 |
8 | System.out.println(str.substring(0,5));
9 | System.out.println(str.substring(6,8));
10 | System.out.println(str.substring(9,str.length()));
11 | String str2="Java is Fun";
12 | System.out.println(str2.substring(0,4));
13 | System.out.println(str2.substring(5,7));
14 | //Break till 1:49
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/org/class11/Notes.txt:
--------------------------------------------------------------------------------
1 | String Class:
2 | The Most widely used class in java and almost
3 | every other programming language. Most of the
4 | information inside a computer is stored and
5 | processed in the form of text.
6 |
--------------------------------------------------------------------------------
/src/main/java/org/class11/T2String.java:
--------------------------------------------------------------------------------
1 | package org.class11;
2 |
3 | public class T2String {
4 | public static void main(String[] args) {
5 |
6 | String str="Java is Fun";
7 | // count how many times letter a has appeared in the String
8 |
9 |
10 | int count=0;
11 |
12 | for (int i = 0; i < str.length(); i++) {
13 |
14 | if(str.charAt(i)=='a'){
15 | count++;
16 | }
17 | }
18 |
19 | System.out.println(count);
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/class11/T3String.java:
--------------------------------------------------------------------------------
1 | package org.class11;
2 |
3 | public class T3String {
4 | public static void main(String[] args) {
5 | String str="Today is Saturday";
6 | // print the all the index of letter a from above string
7 |
8 | for (int i = 0; i < str.length(); i++) {
9 |
10 | if(str.charAt(i)=='a'){
11 | System.out.println(i); }
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/class11/T4String.java:
--------------------------------------------------------------------------------
1 | package org.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 T4String {
10 | public static void main(String[] args) {
11 | String str="hello";
12 |
13 | if(!str.isEmpty()){
14 | int len=str.length();
15 | if(len>=3&& len%2!=0){
16 | System.out.println(str.charAt(len/2));
17 | }
18 |
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/class12/E1StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.class12;
2 |
3 | public class E1StringDemo {
4 | public static void main(String[] args) {
5 |
6 | String str="Its Savera's Birthday today. Its Sunday. Today is Java Class";
7 | String [] strArr= str.split("[.]");
8 | System.out.println(strArr.length);
9 | System.out.println(strArr[2].trim());
10 |
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/class12/E2StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.class12;
2 |
3 | public class E2StringDemo {
4 | public static void main(String[] args) {
5 |
6 | String str="Its Savera's Birthday today. Its Sunday. Today is Java Class";
7 | String [] wordArr= str.split(" ");
8 | System.out.println(wordArr.length);
9 | System.out.println(wordArr[0]);
10 |
11 |
12 |
13 |
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/org/class12/E3StringBuilder.java:
--------------------------------------------------------------------------------
1 | package org.class12;
2 |
3 | public class E3StringBuilder {
4 | public static void main(String[] args) {
5 |
6 | StringBuilder sb=new StringBuilder("Hello World");
7 | // System.out.println(sb.reverse());
8 | System.out.println(sb.deleteCharAt(0));
9 | System.out.println(sb.insert(1,"H"));
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/org/class12/E4Methods.java:
--------------------------------------------------------------------------------
1 | package org.class12;
2 |
3 | public class E4Methods {
4 |
5 |
6 | }
7 |
--------------------------------------------------------------------------------
/src/main/java/org/class12/Math.java:
--------------------------------------------------------------------------------
1 | package org.class12;
2 |
3 | public class Math {
4 |
5 | void printHello(){
6 | System.out.println("Hello World");
7 | System.out.println("Hello batch 18");
8 | }
9 |
10 | void printHelloManyTimes(){
11 |
12 | for (int i = 0; i < 5; i++) {
13 | System.out.println("Hello World");
14 | }
15 | }
16 |
17 | void printNTimes(int number){
18 |
19 | for (int i = 0; i < number; i++) {
20 | System.out.println("Hello World");
21 | }
22 |
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/class12/MathTester.java:
--------------------------------------------------------------------------------
1 | package org.class12;
2 |
3 | public class MathTester {
4 | public static void main(String[] args) {
5 |
6 | Math m= new Math();
7 | // m.printHello();
8 | // m.printHelloManyTimes();
9 | m.printNTimes(10);
10 | String str="heelo";
11 | str.charAt(0);
12 |
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/class12/Notes.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SyntaxTechnologies/SDETJavaBatch18/e16838663b9cb702655b0e0ed2f3310b5ab149ef/src/main/java/org/class12/Notes.txt
--------------------------------------------------------------------------------
/src/main/java/org/class12/StringVsStringBuilder.java:
--------------------------------------------------------------------------------
1 | package org.class12;
2 |
3 | public class StringVsStringBuilder {
4 | public static void main(String[] args) {
5 |
6 | String address="USA";
7 | String address1="USA";
8 | String address2="USA";
9 | String address3="USA";
10 | String address4="USA";
11 | String address5="USA";
12 | address5="Canada";
13 |
14 | String ad="Canada";
15 | StringBuffer sb=new StringBuffer("Hello");
16 |
17 |
18 | // Break till 11:50
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/class12/T1String.java:
--------------------------------------------------------------------------------
1 | package org.class12;
2 | /*
3 | Create a String that will hold a sentence.
4 | Write a program to get a new String without any spaces.
5 | */
6 | public class T1String {
7 | public static void main(String[] args) {
8 |
9 | String str="Java is very easy";
10 | String newStr=str.replaceAll(" ","");
11 | System.out.println(newStr);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/class12/T2String.java:
--------------------------------------------------------------------------------
1 | package org.class12;
2 |
3 | public class T2String {
4 | public static void main(String[] args) {
5 | String str="bkfdSAHBDSH2232398487#Y*$%";
6 | System.out.println(str.replaceAll("[^A-Za-z]","").length());
7 |
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/org/class12/T3String.java:
--------------------------------------------------------------------------------
1 | package org.class12;
2 | /*
3 | You have a String a=”Is it saturday? Is it raining?
4 | Do we have a Java Class today?” How would you find out how many
5 | sentences are in that String?
6 | */
7 | public class T3String {
8 | public static void main(String[] args) {
9 | String str="Is it saturday? Is it raining? Do we have a Java Class today?";
10 | System.out.println(str.split("[?]").length);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/org/class12/T5String.java:
--------------------------------------------------------------------------------
1 | package org.class12;
2 | /*
3 | How would you reverse a String word by word? for example
4 | // input=>This is sentence i want to reverse
5 | // output=>sihT si ecnetnes i tnaw ot esrever
6 | */
7 | public class T5String {
8 | public static void main(String[] args) {
9 |
10 | String str="This is sentence i want to reverse";
11 | String [] words=str.split(" ");
12 |
13 | for (String w:words){
14 |
15 | for (int i = w.length()-1; i>=0; i--) {
16 | System.out.print(w.charAt(i));
17 | }
18 | System.out.print(" ");
19 |
20 |
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/org/class12/T6String.java:
--------------------------------------------------------------------------------
1 | package org.class12;
2 | /*
3 | How would you check if String is palindrome or not? aba=> true
4 | Abbc =>false
5 |
6 | */
7 | public class T6String {
8 | public static void main(String[] args) {
9 |
10 | String str="car";
11 | String reversedWord="";
12 | for (int i = str.length()-1; i>=0; i--) {
13 | reversedWord=reversedWord+str.charAt(i);
14 | }
15 | if(str.equalsIgnoreCase(reversedWord)){
16 | System.out.println("Its a Palindrome");
17 | }else{
18 | System.out.println("It's not a Palindrome");
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/class12/T7String.java:
--------------------------------------------------------------------------------
1 | package org.class12;
2 |
3 | public class T7String {
4 | }
5 |
--------------------------------------------------------------------------------
/src/main/java/org/class13/AccountTester2.java:
--------------------------------------------------------------------------------
1 | package org.class13;
2 |
3 | import org.class14.Account;
4 |
5 | public class AccountTester2 {
6 | public static void main(String[] args) {
7 | Account a=new Account();
8 | // System.out.println(a.accountNumber);
9 | // a.printHello();
10 | a.Hello();
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/org/class13/E1Methods.java:
--------------------------------------------------------------------------------
1 | package org.class13;
2 |
3 | import java.util.Scanner;
4 |
5 | public class E1Methods {
6 | public static void main(String[] args) {
7 | String str="Java";
8 | int index= str.indexOf('J');
9 | Scanner scanner=new Scanner(System.in);
10 | int input=scanner.nextInt();
11 | }
12 | }
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/main/java/org/class13/Math.java:
--------------------------------------------------------------------------------
1 | package org.class13;
2 |
3 | /*
4 | i want to create a method and print the results
5 | */
6 | public class Math {
7 |
8 | void add(int input1,int input2){
9 | System.out.println(input1+input2);
10 | }
11 |
12 |
13 | int multiply(int num1,int num2){
14 | System.out.println(num1*num2);
15 | return num1*num2;
16 |
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/org/class13/MathTester.java:
--------------------------------------------------------------------------------
1 | package org.class13;
2 |
3 | public class MathTester {
4 | public static void main(String[] args) {
5 | Math obj= new Math();
6 | obj.add(10,10);
7 |
8 | int r= obj.multiply(10,2);
9 | System.out.println(r);
10 | String str="Java";
11 | System.out.println(str.length());
12 | str.isEmpty();
13 | str.charAt(2);
14 | // return char
15 | // charAt
16 | //int
17 |
18 | str.concat("Python");
19 | //String
20 | //concat
21 | //String
22 |
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/class13/Notes.txt:
--------------------------------------------------------------------------------
1 | Methods in Java:
2 | Methods/Function/Behaviours are blocks
3 | of code. They contain statement(lines of code) which
4 | are executed when a method is called.
5 | A method in java has a return type(output) name and parameters/arguments(inputs).
6 |
7 | Why should we use methods?
8 | Methods help us reuse the code. When we need to share/reuse a
9 | piece of code within our project or with others we can
10 | create our own classes define methods inside those classes
11 | and we can start reusing/sharing them.
12 |
13 | Syntax of the method:
14 | returnType(output) nameOfTheMethod (input/parameters){
15 |
16 |
17 | }
--------------------------------------------------------------------------------
/src/main/java/org/class13/Printer.java:
--------------------------------------------------------------------------------
1 | package org.class13;
2 |
3 | public class Printer {
4 |
5 | void printHello(){
6 | System.out.println("Hello World");
7 | }
8 |
9 | void printWord(String word){
10 | System.out.println(word);
11 | }
12 |
13 | void printManyTimes(String word,int n){
14 |
15 | for (int i = 0; i < n; i++) {
16 | System.out.println(word);
17 | }
18 | }
19 |
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/class13/PrinterTester.java:
--------------------------------------------------------------------------------
1 | package org.class13;
2 |
3 | public class PrinterTester {
4 | public static void main(String[] args) {
5 | Printer p=new Printer();
6 |
7 | // p.printHello();
8 | //p.printWord("Java");
9 | p.printManyTimes("Java",5);
10 | // Break till 8:49
11 |
12 |
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/class13/Task1.java:
--------------------------------------------------------------------------------
1 | package org.class13;
2 |
3 | public class Task1 {
4 |
5 | void printLarger(int num1,int num2){
6 |
7 | if(num1>num2){
8 | System.out.println(num1);
9 | }else{
10 | System.out.println(num2);
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/class13/Task2.java:
--------------------------------------------------------------------------------
1 | package org.class13;
2 |
3 | public class Task2 {
4 | void oddOrEven(int a){
5 | if(a%2==0){
6 | System.out.println("Even");
7 | }else{
8 | System.out.println("Odd");
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/org/class13/Task3.java:
--------------------------------------------------------------------------------
1 | package org.class13;
2 |
3 | public class Task3 {
4 | void isPalidrome(String word) {
5 | String reverseName = " ";
6 |
7 | for (int i = word.length() - 1; i >= 0; i--) {
8 | reverseName = reverseName + word.charAt(i);
9 | }
10 | if (word.equalsIgnoreCase(reverseName)) {
11 | System.out.println("It is a Palindrome");
12 | } else {
13 | System.out.println("It is not a Palindrome");
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/main/java/org/class14/AccountTester.java:
--------------------------------------------------------------------------------
1 | package org.class14;
2 |
3 | public class AccountTester {
4 | public static void main(String[] args) {
5 |
6 | Account a=new Account();
7 | // System.out.println(a.password);
8 | // a.printInfo();
9 | System.out.println(a.accountNumber);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/org/class14/Cat.java:
--------------------------------------------------------------------------------
1 | package org.class14;
2 |
3 | public class Cat {
4 | //instance variable
5 | String name="kitti";
6 |
7 | void printName(){
8 | //local Vairable
9 | String name="Pishak";
10 | System.out.println(name);
11 | }
12 |
13 | public static void main(String[] args) {
14 | Cat c=new Cat();
15 | c.printName();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/class14/CatTester.java:
--------------------------------------------------------------------------------
1 | package org.class14;
2 |
3 | import org.class15.Cat;
4 |
5 | public class CatTester {
6 | public static void main(String[] args) {
7 | org.class15.Cat c=new Cat("Kitti","White",13);
8 | c.printInfo();
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/class14/Dog.java:
--------------------------------------------------------------------------------
1 | package org.class14;
2 |
3 | public class Dog {
4 | String name;
5 |
6 | void printInfo(){
7 | System.out.println(name);
8 | }
9 |
10 | public static void main(String[] args) {
11 |
12 | Dog d1=new Dog();
13 | d1.name="Jacki";
14 | d1.printInfo();
15 | // Break till 11:53
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/org/class14/E1LocalVar.java:
--------------------------------------------------------------------------------
1 | package org.class14;
2 |
3 | public class E1LocalVar {
4 | public static void main(String[] args) {
5 |
6 | int age=10;
7 |
8 | if(10<5){
9 | System.out.println(age);
10 | String name="Jerry";
11 | }
12 |
13 | if(10>5){
14 | // System.out.println(name);
15 |
16 | }
17 |
18 | }
19 |
20 | void printAge(){
21 | // System.out.println(age);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/org/class14/Horse.java:
--------------------------------------------------------------------------------
1 | package org.class14;
2 |
3 | public class Horse {
4 | String name="Asp";
5 |
6 | void printInfo(){
7 | int age=10;
8 | System.out.println(age);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/class14/HorseTester.java:
--------------------------------------------------------------------------------
1 | package org.class14;
2 |
3 | public class HorseTester {
4 | public static void main(String[] args) {
5 | Horse h=new Horse();
6 | h.printInfo();
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/org/class14/MathDemo.java:
--------------------------------------------------------------------------------
1 | package org.class14;
2 |
3 | public class MathDemo {
4 |
5 | static int add(int num1,int num2){
6 | return num1+num2;
7 | }
8 |
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/class14/Person.java:
--------------------------------------------------------------------------------
1 | package org.class14;
2 |
3 | public class Person {
4 |
5 | static int noOfEye=2;
6 | String name;
7 | int age;
8 | double weight;
9 |
10 | //Instance method
11 | void printInfo(){
12 |
13 | System.out.println(name+" "+age+" "+weight);
14 | }
15 |
16 | //Static Method
17 | static void printNoOfEyes(){
18 | System.out.println(noOfEye);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/class14/PersonTester.java:
--------------------------------------------------------------------------------
1 | package org.class14;
2 |
3 | public class PersonTester {
4 | public static void main(String[] args) {
5 | Person p1=new Person();
6 | p1.name="Zeeshan";
7 | p1.age=22;
8 | p1.weight=60;
9 | p1.printInfo();
10 | System.out.println(Person.noOfEye);
11 | Person.noOfEye=3;
12 | Person p2=new Person();
13 | p2.name="Sino";
14 | p2.age=25;
15 | p2.weight=70;
16 | p2.printInfo();
17 | System.out.println(Person.noOfEye);
18 |
19 | Person.printNoOfEyes();
20 |
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/org/class14/T1.java:
--------------------------------------------------------------------------------
1 | package org.class14;
2 |
3 | public class T1 {
4 | static int dValue(int num){
5 | return num*2;
6 | }
7 |
8 | public static void main(String[] args) {
9 |
10 | System.out.println(T1.dValue(10));
11 | // break till 1:54
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/class14/T2.java:
--------------------------------------------------------------------------------
1 | package org.class14;
2 |
3 | public class T2 {
4 |
5 | int sumArray(int [] arr){
6 |
7 | int sum=0;
8 | for (int i = 0; i < arr.length; i++) {
9 | sum=sum+arr[i];
10 | }
11 | return sum;
12 | }
13 |
14 | public static void main(String[] args) {
15 |
16 | T2 t=new T2();
17 | int [] numbers={10,10,20};
18 | int sum=t.sumArray(numbers);
19 | System.out.println(sum);
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/class15/Ambient-music-free.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SyntaxTechnologies/SDETJavaBatch18/e16838663b9cb702655b0e0ed2f3310b5ab149ef/src/main/java/org/class15/Ambient-music-free.mp3
--------------------------------------------------------------------------------
/src/main/java/org/class15/Cat.java:
--------------------------------------------------------------------------------
1 | package org.class15;
2 |
3 | public class Cat {
4 | private String name;
5 | private String color;
6 | private int age;
7 |
8 | public Cat(String name,String color,int age){
9 | this.name=name;
10 | this.color=color;
11 | this.age=age;
12 | }
13 |
14 | public void printInfo(){
15 |
16 | System.out.println(name+" "+color+" "+age);
17 | }
18 | public static void main(String[] args) {
19 | Cat c=new Cat("Kitti","White",13);
20 | c.printInfo();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/class15/CatTester.java:
--------------------------------------------------------------------------------
1 | package org.class15;
2 |
3 | public class CatTester {
4 | public static void main(String[] args) {
5 | Cat c=new Cat("Kitti","White",13);
6 | c.printInfo();
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/org/class15/Demo.java:
--------------------------------------------------------------------------------
1 | package org.class15;
2 |
3 | public class Demo {
4 |
5 | Demo(){
6 | System.out.println("1");
7 | }
8 |
9 | Demo(int age){
10 | System.out.println("2");
11 | }
12 |
13 | Demo(String name){
14 | System.out.println("3");
15 | }
16 | Demo(String name,int age){
17 | System.out.println("4");
18 | }
19 |
20 | Demo(int age,String name){
21 | System.out.println("5");
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/org/class15/DemoTester.java:
--------------------------------------------------------------------------------
1 | package org.class15;
2 |
3 | public class DemoTester {
4 | public static void main(String[] args) {
5 |
6 | Demo d=new Demo("Zion Lights ",10);
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/org/class15/Dog.java:
--------------------------------------------------------------------------------
1 | package org.class15;
2 |
3 | public class Dog {
4 |
5 | private String name;
6 | private String breed;
7 | private String color;
8 | private int age;
9 |
10 | public Dog(String dName,String dBreed,String dColor, int dAge){
11 | name=dName;
12 | breed=dBreed;
13 | color=dColor;
14 | if(dAge<30){
15 | age=dAge;
16 | }else{
17 | System.out.println("Wrong age");
18 | }
19 |
20 | }
21 |
22 | void printInfo(){
23 | System.out.println(name+" "+breed+" "+color+" "+age);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/class15/DogTester.java:
--------------------------------------------------------------------------------
1 | package org.class15;
2 |
3 | public class DogTester {
4 | public static void main(String[] args) {
5 | Dog d1=new Dog("Jacky","German","Black",10);
6 | d1.printInfo();
7 | //break till 11:54
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/org/class15/E1AudioPlayer.java:
--------------------------------------------------------------------------------
1 | package org.class15;
2 |
3 | import javazoom.jl.decoder.JavaLayerException;
4 | import javazoom.jl.player.Player;
5 |
6 | import java.io.FileInputStream;
7 | import java.io.FileNotFoundException;
8 |
9 | public class E1AudioPlayer {
10 | public static void main(String[] args) throws FileNotFoundException, JavaLayerException {
11 |
12 | FileInputStream fis=new FileInputStream("C:\\Users\\Syntax\\IdeaProjects\\SDETJavaB18\\src\\main\\java\\org\\class15\\Ambient-music-free.mp3");
13 | Player player=new Player(fis);
14 | player.play();
15 |
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/class15/E1BrowserDemo.java:
--------------------------------------------------------------------------------
1 | package org.class15;
2 |
3 | import org.openqa.selenium.chrome.ChromeDriver;
4 |
5 | public class E1BrowserDemo {
6 | public static void main(String[] args) {
7 |
8 | ChromeDriver chromeDriver=new ChromeDriver();
9 | chromeDriver.get("https://facebook.com");
10 | chromeDriver.close();
11 |
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/class15/Notes.txt:
--------------------------------------------------------------------------------
1 | Constructor:
2 | Constructor in java a piece of code
3 | that helps us build the object of a
4 | class easily.
5 |
--------------------------------------------------------------------------------
/src/main/java/org/class15/PersonTester.java:
--------------------------------------------------------------------------------
1 | package org.class15;
2 |
3 | public class PersonTester {
4 | public static void main(String[] args) {
5 |
6 | Person p=new Person("Zion",22,70,90000,"Java");
7 | Person p2=new Person("Zion",22,70,90000);
8 |
9 |
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/org/class15/Student.java:
--------------------------------------------------------------------------------
1 | package org.class15;
2 |
3 | public class Student {
4 | private String name;
5 | private double s1Marks;
6 | private double s2Marks;
7 | private double s3Marks;
8 | public Student(String sName,double m1,double m2,double m3){
9 | name=sName;
10 | s1Marks=m1;
11 | s2Marks=m2;
12 | s3Marks=m3;
13 | }
14 |
15 | public void calcAvg(){
16 |
17 | double avg=(s1Marks+s2Marks+s3Marks)/3;
18 | System.out.println(name+"s Avg Marks are "+avg);
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/class15/StudentTester.java:
--------------------------------------------------------------------------------
1 | package org.class15;
2 |
3 | public class StudentTester {
4 | public static void main(String[] args) {
5 | Student s1=new Student("Nick",91,90,85);
6 | s1.calcAvg();
7 |
8 | Student s2=new Student("James",55,70,85);
9 | s2.calcAvg();
10 | // Break till 1:50
11 |
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/class15/T1.java:
--------------------------------------------------------------------------------
1 | package org.class15;
2 |
3 | public class T1 {
4 |
5 | T1(){
6 | System.out.println("Empty");
7 | }
8 |
9 | T1(String s){
10 | System.out.println("With one parameter");
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/org/class15/T1Tester.java:
--------------------------------------------------------------------------------
1 | package org.class15;
2 |
3 | public class T1Tester {
4 |
5 | public static void main(String[] args) {
6 |
7 | new T1();
8 | new T1("Str");
9 |
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/org/class15/Teacher.java:
--------------------------------------------------------------------------------
1 | package org.class15;
2 |
3 | public class Teacher {
4 | private String name;
5 | private String address;
6 |
7 | private int age;
8 | private double weight;
9 |
10 |
11 |
12 | public Teacher(String name, String address, int age) {
13 | this.name = name;
14 | this.address = address;
15 | this.age = age;
16 | }
17 |
18 | public Teacher(String name, String address, int age, double weight) {
19 | this(name, address, age);
20 | this.weight = weight;
21 | }
22 |
23 | void printInfo(){
24 | System.out.println(name+" "+address);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/org/class16/Animal.java:
--------------------------------------------------------------------------------
1 | package org.class16;
2 |
3 | public class Animal{
4 | String name;
5 | String color;
6 | int age;
7 | double weight;
8 |
9 | void sleep(){
10 | System.out.println("ZzzzZZZzz.");
11 | }
12 | public void printInfo(){
13 | System.out.println(name+" "+color+" "+age+" "+weight);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/org/class16/Animal2.java:
--------------------------------------------------------------------------------
1 | package org.class16;
2 |
3 | public class Animal2 {
4 | void sleep(){
5 | System.out.println("Never sleep");
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/org/class16/AnimalTester.java:
--------------------------------------------------------------------------------
1 | package org.class16;
2 |
3 | public class AnimalTester {
4 | public static void main(String[] args) {
5 |
6 | Dog d=new Dog();
7 | d.name="Jacky";
8 | d.color="Black";
9 | d.age=10;
10 | d.weight=22;
11 | d.printInfo();
12 | d.bark();
13 |
14 | Cat c=new Cat();
15 | c.name="lulu";
16 | c.color="White";
17 | c.age=2;
18 | c.weight=3;
19 | c.sleep();
20 | c.printInfo();
21 |
22 |
23 | Animal a=new Animal();
24 | a.name="lol";
25 | a.sleep();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/class16/Cat.java:
--------------------------------------------------------------------------------
1 | package org.class16;
2 |
3 | public class Cat extends Animal{
4 |
5 | }
6 |
--------------------------------------------------------------------------------
/src/main/java/org/class16/Dog.java:
--------------------------------------------------------------------------------
1 | package org.class16;
2 |
3 | public class Dog extends Animal{
4 | void bark(){
5 | System.out.println("Wuff wuff!");
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/org/class16/E.java:
--------------------------------------------------------------------------------
1 | package org.class16;
2 |
3 | public class E {
4 | public static void printF(){
5 | System.out.println("Hello Batch 18");
6 | }
7 | }
8 | class F extends E{
9 |
10 | }
11 |
12 | class ETester{
13 | public static void main(String[] args) {
14 | F.printF();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/org/class16/MultilevelTester.java:
--------------------------------------------------------------------------------
1 | package org.class16;
2 |
3 | public class MultilevelTester {
4 |
5 |
6 | public static void main(String[] args) {
7 | Audi a=new Audi();
8 | a.color="Black";
9 | }
10 | }
11 | // Break 8:55
12 | class Vehicle{
13 | String color;
14 | }
15 |
16 | class Car extends Vehicle{
17 | int noOfDoors=4;
18 | }
19 |
20 | class Audi extends Car{
21 |
22 | boolean badEngines=true;
23 | }
--------------------------------------------------------------------------------
/src/main/java/org/class16/Notes.txt:
--------------------------------------------------------------------------------
1 | Inheritance:
2 | Inheritance allows us to build classes from
3 | existing classes. We can inherit fields and methods
4 | from existing classes if we need them in other classes.
5 | There are 5 major types of inheritance.
6 | 1) Single Inheritance.
7 | 2) Hierarchical Inheritance.
8 | 3) Multilevel Inheritance.
9 |
--------------------------------------------------------------------------------
/src/main/java/org/class16/Person.java:
--------------------------------------------------------------------------------
1 | package org.class16;
2 |
3 | public class Person {
4 | String name;
5 | int age;
6 | double weight;
7 | void printInfo(){
8 | System.out.println(name+" "+age+" "+weight);
9 | }
10 | }
11 | class Student extends Person{
12 |
13 | char grade;
14 | void study(){
15 |
16 | }
17 | }
18 |
19 | class StudentTester{
20 | public static void main(String[] args) {
21 | Student s=new Student();
22 | s.age=12;
23 | }
24 | }
--------------------------------------------------------------------------------
/src/main/java/org/class16/Teacher.java:
--------------------------------------------------------------------------------
1 | package org.class16;
2 |
3 | public class Teacher {
4 | String name;
5 | String subject;
6 | int hoursOfTeaching;
7 |
8 | void teach(){
9 | System.out.println("teaching......");
10 | }
11 | void joke(){
12 | System.out.println("hahha");
13 | }
14 | }
15 | class MathTeacher extends Teacher{
16 |
17 | void teachMath(){
18 | System.out.println("Teaching Math");
19 | }
20 | }
21 |
22 | class ChemistryTeacher extends Teacher{
23 |
24 | void teachChem(){
25 | System.out.println("HCL is Salt");
26 | }
27 |
28 | }
29 | class PianoTeacher extends Teacher {
30 |
31 | void teachPiano(){
32 | System.out.println("Teaching Piano");
33 | }
34 | }
--------------------------------------------------------------------------------
/src/main/java/org/class16/TeacherTester.java:
--------------------------------------------------------------------------------
1 | package org.class16;
2 |
3 | public class TeacherTester {
4 | public static void main(String[] args) {
5 | Teacher t=new Teacher();
6 | t.joke();
7 |
8 | MathTeacher mt=new MathTeacher();
9 | mt.hoursOfTeaching=45;
10 | mt.teachMath();
11 |
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/class16/X.java:
--------------------------------------------------------------------------------
1 | package org.class16;
2 |
3 | public class X {
4 | void printt(){
5 | System.out.println("Hahahahah");
6 | }
7 | }
8 |
9 | class Y extends X {
10 | void print(){
11 | System.out.println("Lalalala");
12 | }
13 |
14 |
15 | }
16 |
17 | class Z extends Y{
18 | void printtt(){
19 | System.out.println("Wawawa");
20 | }
21 | }
--------------------------------------------------------------------------------
/src/main/java/org/class17/AnimalTester.java:
--------------------------------------------------------------------------------
1 | package org.class17;
2 |
3 | public class AnimalTester {
4 | public static void main(String[] args) {
5 |
6 | //Animal a=new Animal("Jacky","black",10,15);
7 | //a.printInfo();
8 |
9 | // Dog dog=new Dog("Jacky","White",12,22);
10 |
11 | new Cat();
12 | // Break till 8:57
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/class17/Notes.txt:
--------------------------------------------------------------------------------
1 | Super Keyword:
2 | Super keyword is used to access fields/methods/constructor
3 | from the parent class when there is an inheritance relationship
4 | between the classes.
--------------------------------------------------------------------------------
/src/main/java/org/class17/Parent.java:
--------------------------------------------------------------------------------
1 | package org.class17;
2 |
3 | class GrandParent{
4 | GrandParent(){
5 | System.out.println("Granpa");
6 | }
7 | }
8 |
9 | public class Parent extends GrandParent {
10 | Parent(){
11 | System.out.println("Parent is born");
12 | }
13 | String name="israel";
14 |
15 | }
16 | class Child extends Parent{
17 |
18 | Child(){
19 | System.out.println("Child is Born");
20 | }
21 | void print(){
22 |
23 | System.out.println(name);
24 | }
25 | }
26 |
27 | class Tester{
28 | public static void main(String[] args) {
29 | Child c=new Child();
30 | c.print();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/org/class18/AnimalTester.java:
--------------------------------------------------------------------------------
1 | package org.class18;
2 |
3 | public class AnimalTester {
4 | public static void main(String[] args) {
5 | Dog d=new Dog("Jacky","Black",12,25.);
6 | d.printInfo();
7 |
8 | //Break till 11:56
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/class18/Degree.java:
--------------------------------------------------------------------------------
1 | package org.class18;
2 |
3 | public class Degree {
4 |
5 | public void getPreReq(){
6 | System.out.println("To Get a Degree we need to have a School diploma");
7 | }
8 | }
9 |
10 | class Master extends Degree{
11 |
12 | public void getPreReq(){
13 | System.out.println("To get a Masters degree we need to have Bachelors Degree");
14 | }
15 | }
16 |
17 | class Bachelors extends Degree{
18 |
19 | }
20 |
21 | class DegreeTester{
22 | public static void main(String[] args) {
23 | Master m=new Master();
24 | m.getPreReq();
25 | Bachelors b=new Bachelors();
26 | b.getPreReq();
27 | }
28 | }
--------------------------------------------------------------------------------
/src/main/java/org/class18/FinalDemo.java:
--------------------------------------------------------------------------------
1 | package org.class18;
2 |
3 | public class FinalDemo {
4 | final String greetings="Hello Everyone";
5 | public static final String name="Kawoon";
6 |
7 | void test(){
8 | // greetings="Hello Guys";
9 | final int hananeAge=16;
10 | // hananeAge=30;
11 |
12 |
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/org/class18/Notes.txt:
--------------------------------------------------------------------------------
1 | MethodOverride:
2 | Method-overriding allows child classes to modify
3 | methods which are being inherited from the parent
4 | classes.
5 | Benefits of MethodOverride:
6 | Its give flexibility to child classes to change methods
7 | which are coming from parents if they want to.
8 |
9 |
--------------------------------------------------------------------------------
/src/main/java/org/class18/Parent.java:
--------------------------------------------------------------------------------
1 | package org.class18;
2 |
3 | public class Parent {
4 |
5 | void marry(){
6 | System.out.println("Marry the girl that we have selected for you");
7 | }
8 | void sleep(){
9 | System.out.println("Sleep 8 hours");
10 | }
11 | }
12 |
13 | class Karimi extends Parent{
14 |
15 |
16 | void marry(){
17 | System.out.println("I want to marry Scarlett Johnansson");
18 | }
19 | }
20 |
21 | class Tester{
22 | public static void main(String[] args) {
23 | Karimi k=new Karimi();
24 | k.marry();
25 | k.sleep();
26 | }
27 | }
--------------------------------------------------------------------------------
/src/main/java/org/class18/PersonTester.java:
--------------------------------------------------------------------------------
1 | package org.class18;
2 |
3 | public class PersonTester {
4 | public static void main(String[] args) {
5 | Student s=new Student("Hanane",16,20,95);
6 | s.printInfo();
7 | System.out.println(s.getName());
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/org/class18/Printer.java:
--------------------------------------------------------------------------------
1 | package org.class18;
2 |
3 | public class Printer {
4 |
5 | private void print(){
6 | System.out.println("Hello");
7 | }
8 |
9 | private void print(String word){
10 | System.out.println(word);
11 | }
12 |
13 | public static void main(String[] args) {
14 | Printer p=new Printer();
15 | p.print();
16 | p.print("Java");
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/org/class18/StringBuilderDemo.java:
--------------------------------------------------------------------------------
1 | package org.class18;
2 |
3 | public class StringBuilderDemo {
4 |
5 | public static void main(String[] args) {
6 |
7 | String str="Hello";
8 | System.out.println( str.concat("And Welcome"));
9 |
10 | StringBuilder sb=new StringBuilder("Hello");
11 | sb.append("And Welcome");
12 | System.out.println(sb);
13 |
14 | StringBuilder s= new StringBuilder();
15 | for (int i = 0; i < 1000; i++) {
16 | s.append(i);
17 | }
18 | System.out.println(s);
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/class18/StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.class18;
2 |
3 | public class StringDemo {
4 | public static void main(String[] args) {
5 | String str="My Phone number is 911";
6 | str=str.replaceAll("[^0-9]","");
7 | System.out.println(str);
8 |
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/class19/AnimalTester.java:
--------------------------------------------------------------------------------
1 | package org.class19;
2 |
3 | public class AnimalTester {
4 | public static void main(String[] args) {
5 |
6 | Animal a=new Dog("Jacky","Black",1,12);
7 |
8 | Dog d=(Dog)a;
9 | d.bark();
10 |
11 | double [] arr= {10,20};
12 |
13 | Dog d1=new Dog("Jacky","Black",1,12);
14 | Cat c1=new Cat("Lovly","white",1,12);
15 | Animal a1=new Animal("Lovly","white",1,12);
16 |
17 | Animal [] animals={d1,c1,a1};
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/org/class19/ComputerTester.java:
--------------------------------------------------------------------------------
1 | package org.class19;
2 |
3 | public class ComputerTester {
4 | public static void main(String[] args) {
5 | Computer [] arr={new Apple("Apple",1000,250)
6 | ,new Dell("Dell",2000,250),
7 | new HP("HP",1000,250),
8 | new Lenovo("Lenovo",1000,250)};
9 | for (Computer c: arr){
10 | c.printInfo();
11 | c.playVideo();
12 | c.browseInternet();
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/src/main/java/org/class19/E1ObjectTypeCasting.java:
--------------------------------------------------------------------------------
1 | package org.class19;
2 |
3 | public class E1ObjectTypeCasting {
4 | public static void main(String[] args) {
5 |
6 | int number=10;
7 | double num=number;
8 | System.out.println(num);
9 |
10 | double num2=10.5;
11 | int num3=(int)num2;
12 | System.out.println(num3);
13 |
14 |
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/org/class19/E2Poly.java:
--------------------------------------------------------------------------------
1 | package org.class19;
2 |
3 | public class E2Poly {
4 | public static void main(String[] args) {
5 | Dog d1=new Dog("Jacky","Brown",10,25);
6 | Dog d2=new Dog("Macky","black",10,25);
7 | Cat c1=new Cat("lovly","black",10,25);
8 | Animal a1=new Animal("Animal","black",10,25);
9 |
10 | Animal [] arr={d1,d2,c1,a1};
11 |
12 | Animal animal=arr[1];
13 | animal.printInfo();
14 |
15 |
16 | Cat c=(Cat)arr[2];
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/org/class19/E3Poly.java:
--------------------------------------------------------------------------------
1 | package org.class19;
2 |
3 | import org.openqa.selenium.edge.EdgeDriver;
4 |
5 | public class E3Poly {
6 | public static void main(String[] args) throws InterruptedException {
7 |
8 | /* ChromeDriver chromeDriver=new ChromeDriver();
9 | chromeDriver.navigate().to("https://amazon.com");
10 | Thread.sleep(2000);
11 | System.out.println( chromeDriver.getTitle());
12 | chromeDriver.close();*/
13 |
14 | /*FirefoxDriver f=new FirefoxDriver();
15 | f.get("https://amazon.com");
16 | f.close();*/
17 |
18 | EdgeDriver edgeDriver=new EdgeDriver();
19 | edgeDriver.get("https://amazon.com");
20 | edgeDriver.close();
21 |
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/org/class19/Notes.txt:
--------------------------------------------------------------------------------
1 | Type casting in object:
2 | Converting the datatype of data. There are two types of
3 | type casting upcasting and down-casting.
4 |
5 |
6 |
7 | PolyMorphism in java:
8 |
--------------------------------------------------------------------------------
/src/main/java/org/class19/StTester.java:
--------------------------------------------------------------------------------
1 | package org.class19;
2 |
3 | public class StTester {
4 | public static void main(String[] args) {
5 | Student[] arr = {new Student(), new SyntaxStudents(), new CollegeStudent(), new SchoolStudent()};
6 | for (Student student : arr) {
7 | student.homework();
8 | student.exam();
9 | student.study();
10 | if(student instanceof SyntaxStudents ){
11 | SyntaxStudents s= (SyntaxStudents)student;
12 | s.play();
13 | }
14 |
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/src/main/java/org/class2/E10Quiz.java:
--------------------------------------------------------------------------------
1 | package org.class2;
2 |
3 | public class E10Quiz {
4 | public static void main(String[] args) {
5 | System.out.println(2+2*2); //6
6 | System.out.println((2+2)*2); //8
7 | System.out.println("10"+10); //1010
8 | /*
9 | when ever there are more than 2 operations on a single
10 | line java executes from left to right for example in below
11 | line "10"+10=>"1010"+10=>101010"
12 | */
13 | System.out.println("10"+10+10);
14 | //10+10=>20+"10"=>"2010"
15 | System.out.println(10+10+"10");
16 | //11:55
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/org/class2/E11VarUpdate.java:
--------------------------------------------------------------------------------
1 | package org.class2;
2 |
3 | public class E11VarUpdate {
4 | public static void main(String[] args) {
5 |
6 | int num=100;
7 | int num2=num+10;
8 | System.out.println(num2); //110
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/class2/E12VarUpdate.java:
--------------------------------------------------------------------------------
1 | package org.class2;
2 |
3 | public class E12VarUpdate {
4 | public static void main(String[] args) {
5 |
6 | int num=100;
7 |
8 | num=num+20;
9 | num=0;
10 | System.out.println(num);
11 |
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/class2/E13ShortHandOp.java:
--------------------------------------------------------------------------------
1 | package org.class2;
2 |
3 | import java.sql.SQLOutput;
4 |
5 | public class E13ShortHandOp {
6 | public static void main(String[] args) {
7 | int num=100;
8 | //num=num+20;
9 | // what ever we have in num add
10 | // 20 to that and store the results back in num
11 | num+=20;
12 |
13 | System.out.println(num);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/org/class2/E14ShortHandOp.java:
--------------------------------------------------------------------------------
1 | package org.class2;
2 |
3 | public class E14ShortHandOp {
4 | public static void main(String[] args) {
5 | int num=10;
6 | num*=10;
7 | System.out.println(num);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/org/class2/E15ShortHandOp.java:
--------------------------------------------------------------------------------
1 | package org.class2;
2 |
3 | public class E15ShortHandOp {
4 |
5 |
6 | public static void main(String[] args) {
7 | int num=100;
8 | num/=20;
9 | System.out.println(num);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/org/class2/E16RelationalOp.java:
--------------------------------------------------------------------------------
1 | package org.class2;
2 |
3 | public class E16RelationalOp {
4 | public static void main(String[] args) {
5 | //is 10 greater than 5? true
6 | System.out.println(10>5);
7 | //is 2 greater than 15? false
8 | System.out.println(2>15);
9 |
10 | boolean is=45>50;
11 | System.out.println(is);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/class2/E17RelationalOp.java:
--------------------------------------------------------------------------------
1 | package org.class2;
2 |
3 | public class E17RelationalOp {
4 | public static void main(String[] args) {
5 |
6 | String a="James";
7 | String b="John";
8 | //System.out.println(a>b); // not allowed
9 | // System.out.println(true>false); // not allowed
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/org/class2/E18RelationalOp.java:
--------------------------------------------------------------------------------
1 | package org.class2;
2 |
3 | public class E18RelationalOp {
4 | public static void main(String[] args) {
5 |
6 | int num1=10;
7 | int num2=20;
8 |
9 | System.out.println(num1>num2); //false
10 | System.out.println(num1 names=new ArrayList<>();
9 | names.add("Maria");
10 | System.out.println(names.size());
11 | names.add("Poorna");
12 | names.add("Damla");
13 | names.add("Kamla");
14 | System.out.println(names.size());
15 | System.out.println(names);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/class22/E1CF.java:
--------------------------------------------------------------------------------
1 | package org.class22;
2 |
3 | import java.util.Arrays;
4 |
5 | public class E1CF {
6 | public static void main(String[] args) {
7 | String name="Maria";
8 | String [] names={"Canan","Halil","Swati"};
9 |
10 | // names[3]="Bikal";
11 |
12 | String[] students=new String[100];
13 | // System.out.println(students.length);
14 | System.out.println(Arrays.toString(students));
15 |
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/org/class22/E2ArrayList.java:
--------------------------------------------------------------------------------
1 | package org.class22;
2 |
3 | import java.util.ArrayList;
4 |
5 | public class E2ArrayList {
6 | public static void main(String[] args) {
7 |
8 | ArrayList names=new ArrayList<>();
9 | System.out.println(names.size());
10 | names.add("Bikal");
11 | System.out.println(names.contains("Bikal"));
12 | System.out.println(names.size());
13 | names.remove("Bikal");
14 | System.out.println(names.size());
15 |
16 |
17 |
18 |
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/org/class22/E4ArrayList.java:
--------------------------------------------------------------------------------
1 | package org.class22;
2 |
3 | import java.util.ArrayList;
4 |
5 | public class E4ArrayList {
6 | public static void main(String[] args) {
7 |
8 | ArrayList names=new ArrayList<>();
9 | names.add("Maria");
10 | names.add("Poorna");
11 | names.add("Damla");
12 | names.add("Kamla");
13 | System.out.println(names);
14 | for (int i = 0; i < names.size(); i++) {
15 | System.out.println(names.get(i));
16 | }
17 |
18 | System.out.println("************");
19 | for(String s:names){
20 | System.out.println(s);
21 | }
22 |
23 |
24 |
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/org/class22/E5ArrayList.java:
--------------------------------------------------------------------------------
1 | package org.class22;
2 |
3 | import java.util.ArrayList;
4 |
5 | public class E5ArrayList {
6 | public static void main(String[] args) {
7 | // print yes if a name contains the
8 | // letter o otherwise no for all names
9 | ArrayList names=new ArrayList<>();
10 | names.add("Maria");
11 | names.add("Poorna");
12 | names.add("Damla");
13 | names.add("Kamla");
14 | for(String s:names){
15 | if(s.contains("o")){
16 | System.out.println("Yes");
17 | }else{
18 | System.out.println("No");
19 | }
20 |
21 | }
22 |
23 |
24 |
25 |
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/class22/EmployeeTester.java:
--------------------------------------------------------------------------------
1 | package org.class22;
2 |
3 | public class EmployeeTester {
4 | public static void main(String[] args) {
5 | /* Person p=new SyntaxEmployee();
6 | Human h=new SyntaxEmployee();
7 | Employee e=new SyntaxEmployee();*/
8 |
9 | SyntaxEmployee e=new SyntaxEmployee();
10 |
11 |
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/class22/Human.java:
--------------------------------------------------------------------------------
1 | package org.class22;
2 |
3 | public interface Human {
4 | void walk();
5 | }
6 |
7 | interface Person{
8 | void talk();
9 |
10 | }
11 |
12 | interface Employee extends Human,Person{
13 | void work();
14 | }
15 |
16 | class SyntaxEmployee implements Employee{
17 |
18 | @Override
19 | public void walk() {
20 | System.out.println("Walking .....");
21 | }
22 |
23 | @Override
24 | public void talk() {
25 |
26 | System.out.println("Talking....");
27 | }
28 |
29 | @Override
30 | public void work() {
31 |
32 | System.out.println("Working...");
33 | }
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/src/main/java/org/class22/MathTester.java:
--------------------------------------------------------------------------------
1 | package org.class22;
2 |
3 | public class MathTester {
4 | public static void main(String[] args) {
5 | // Calculator m=new Math();
6 | /*
7 | we can't create the object of interfaces
8 | */
9 | // Calculator c=new Calculator();
10 | Math m=new Math();
11 | int r= m.add(10,10);
12 | System.out.println(r);
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/org/class22/Notes.txt:
--------------------------------------------------------------------------------
1 | Interface:
2 | Interfaces are contracts. They are used to make sure that every
3 | programmer is on the same page. The use abstraction for this
4 | purpose.
5 | Encapsulation:
6 | Encapsulation says create a class for every entity and define
7 | methods related to that entity in that class instead of putting
8 | everything inside the main method. It also says make your
9 | fields private and define getter setter methods for those
10 | fields.
11 | ==========================================================
12 | Collections Framework:
13 | is a collection of classes and interfaces which allows us to store
14 | and manipulate large amounts of data easily.
--------------------------------------------------------------------------------
/src/main/java/org/class22/T1.java:
--------------------------------------------------------------------------------
1 | package org.class22;
2 |
3 | import java.util.ArrayList;
4 |
5 | public class T1 {
6 | public static void main(String[] args) {
7 |
8 | ArrayList names=new ArrayList<>();
9 | names.add("Sayed");
10 | names.add("Zainab");
11 | names.add("Siavush");
12 | names.add("Heidar");
13 | names.add("Moadassa");
14 |
15 | System.out.println(names.isEmpty());
16 | System.out.println(names.contains("Heidar"));
17 | System.out.println(names.size());
18 | System.out.println(names);
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/class22/T2.java:
--------------------------------------------------------------------------------
1 | package org.class22;
2 |
3 | import java.util.ArrayList;
4 |
5 | public class T2 {
6 | public static void main(String[] args) {
7 | ArrayList words=new ArrayList<>();
8 | words.add("Carlosa");
9 | words.add("Kim Jong Una");
10 | words.add("Nazir");
11 | words.add("Sherif");
12 |
13 | for (int i = 0; i < words.size(); i++) {
14 | if(words.get(i).endsWith("a")){
15 | words.remove(i);
16 | i--;
17 | }
18 | }
19 | System.out.println(words);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/class22/T3.java:
--------------------------------------------------------------------------------
1 | package org.class22;
2 |
3 | import java.util.ArrayList;
4 |
5 | public class T3 {
6 | public static void main(String[] args) {
7 | ArrayList words=new ArrayList<>();
8 | words.add("Carlosa");
9 | words.add("Kim Jong Una");
10 | words.add("Nazir");
11 | words.add("Sherif");
12 |
13 | words.removeIf(x->x.endsWith("a"));
14 | System.out.println(words);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/org/class22/T4.java:
--------------------------------------------------------------------------------
1 | package org.class22;
2 |
3 | import java.util.ArrayList;
4 |
5 | public class T4 {
6 | public static void main(String[] args) {
7 | ArrayList words=new ArrayList<>();
8 | words.add("Carlosa");
9 | words.add("Kim Jong Una");
10 | words.add("Nazir");
11 | words.add("Sherif");
12 | words.forEach(x-> System.out.println(x));
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/class23/E1LinkedList.java:
--------------------------------------------------------------------------------
1 | package org.class23;
2 |
3 | import org.review10.Dog;
4 |
5 | import java.util.LinkedList;
6 |
7 | public class E1LinkedList {
8 | public static void main(String[] args) {
9 | // Inside the <> we write the name of the class
10 | //whose objects we want to store
11 | LinkedList dogs=new LinkedList();
12 | Dog d1=new Dog("Jacky","German",12);
13 | dogs.add(d1);
14 |
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/org/class23/E2LinkedList.java:
--------------------------------------------------------------------------------
1 | package org.class23;
2 |
3 | import java.util.LinkedList;
4 | import java.util.List;
5 |
6 | public class E2LinkedList {
7 | public static void main(String[] args) {
8 |
9 | List names=new LinkedList<>();
10 | names.add("Kat");
11 | names.add("Aaron");
12 | names.add("Maria");
13 | names.add("Aida");
14 | names.remove(0);
15 | System.out.println(names);
16 | System.out.println(names.size());
17 |
18 |
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/class23/E3Sets.java:
--------------------------------------------------------------------------------
1 | package org.class23;
2 |
3 | import java.util.ArrayList;
4 | import java.util.HashSet;
5 |
6 | public class E3Sets {
7 | public static void main(String[] args) {
8 | ArrayList numbers=new ArrayList<>();
9 | numbers.add(10);
10 | numbers.add(20);
11 | numbers.add(10);
12 | System.out.println(numbers);
13 |
14 | HashSet nums=new HashSet<>();
15 | nums.add(10);
16 | nums.add(20);
17 | //no get method in sets
18 | // nums.get(0);
19 | // nums.add(10);
20 | System.out.println(nums);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/class23/E4Sets.java:
--------------------------------------------------------------------------------
1 | package org.class23;
2 |
3 | import java.util.HashSet;
4 | import java.util.Set;
5 |
6 | public class E4Sets {
7 | public static void main(String[] args) {
8 | Set fruit=new HashSet<>();
9 | fruit.add("Mango");
10 | fruit.add("Kiwi");
11 | fruit.add("Apple");
12 | fruit.add("Banana");
13 | fruit.add("Apple");
14 | System.out.println(fruit);
15 |
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/org/class23/E5Sets.java:
--------------------------------------------------------------------------------
1 | package org.class23;
2 |
3 | import java.util.HashSet;
4 |
5 | public class E5Sets {
6 | public static void main(String[] args) {
7 | HashSet fruit=new HashSet<>();
8 | fruit.add("Mango");
9 | fruit.add("Kiwi");
10 | fruit.add("Apple");
11 | fruit.add("Banana");
12 | fruit.add("Apple");
13 | System.out.println(fruit);
14 |
15 |
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/class23/E6Sets.java:
--------------------------------------------------------------------------------
1 | package org.class23;
2 |
3 | import java.util.LinkedHashSet;
4 | import java.util.Set;
5 |
6 | public class E6Sets {
7 | public static void main(String[] args) {
8 | Set fruit=new LinkedHashSet<>();
9 | fruit.add("Mango");
10 | fruit.add("Kiwi");
11 | fruit.add("Apple");
12 | fruit.add("Banana");
13 | fruit.add("Apple");
14 | System.out.println(fruit);
15 |
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/org/class23/E7Sets.java:
--------------------------------------------------------------------------------
1 | package org.class23;
2 |
3 | import java.util.TreeSet;
4 |
5 | public class E7Sets {
6 | public static void main(String[] args) {
7 |
8 | TreeSet numbers=new TreeSet<>();
9 | numbers.add(20);
10 | numbers.add(10);
11 | numbers.add(50);
12 | numbers.add(5);
13 | numbers.add(5);
14 | System.out.println(numbers);
15 | for(int n:numbers){
16 | if(n==20){
17 | System.out.println(n);}
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/org/class23/E8Collection.java:
--------------------------------------------------------------------------------
1 | package org.class23;
2 |
3 | import java.util.ArrayList;
4 | import java.util.LinkedHashSet;
5 | import java.util.TreeSet;
6 |
7 | public class E8Collection {
8 | public static void main(String[] args) {
9 |
10 | ArrayList numbers=new ArrayList<>();
11 | numbers.add(10);
12 | numbers.add(40);
13 | numbers.add(30);
14 | numbers.add(10);
15 | System.out.println(numbers);
16 |
17 | LinkedHashSet uniqueNumber=new LinkedHashSet<>(numbers);
18 | System.out.println(uniqueNumber);
19 |
20 | TreeSet treeSet=new TreeSet<>(uniqueNumber);
21 | System.out.println(treeSet);
22 |
23 | // Break till 8:56
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/class23/Notes:
--------------------------------------------------------------------------------
1 | LinkedList:
2 |
3 | Set:
4 | Sets are very similar to list but they do not
5 | allow duplicate elements.
6 | HashSet:
7 | UpSide:
8 | Its Fast.
9 | DownSide:
10 | They don't store the data in order.
11 | LinkedHashSet:
12 | Upside:
13 | It remembers the order.
14 | Downside:
15 | Its slower than HashSet.
16 | TreeSet:
17 | Upside:
18 | It keeps the data sorted always.
19 | Downside:
20 | Inserting new elements is very slow.
21 |
--------------------------------------------------------------------------------
/src/main/java/org/class23/Student.java:
--------------------------------------------------------------------------------
1 | package org.class23;
2 |
3 | public class Student {
4 | private String name;
5 | private String id;
6 |
7 | public Student(String name, String id) {
8 | this.name = name;
9 | this.id = id;
10 | }
11 | void printInfo(){
12 | System.out.println(name+" "+id);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/class23/T1.java:
--------------------------------------------------------------------------------
1 | package org.class23;
2 |
3 | import java.util.ArrayList;
4 | import java.util.LinkedHashSet;
5 | import java.util.List;
6 | import java.util.Set;
7 |
8 | public class T1 {
9 | public static void main(String[] args) {
10 | List aList=new ArrayList<>();
11 | aList.add("John");
12 | aList.add("Jane");
13 | aList.add("James");
14 | aList.add("Jasmine");
15 | aList.add("Jane");
16 | aList.add("James");
17 | Set names=new LinkedHashSet<>(aList);
18 | aList.clear();
19 | aList.addAll(names);
20 | System.out.println(aList);
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/org/class23/T2.java:
--------------------------------------------------------------------------------
1 | package org.class23;
2 |
3 | import java.util.Set;
4 | import java.util.TreeSet;
5 |
6 | public class T2 {
7 | public static void main(String[] args) {
8 | Set countriesSet = new TreeSet<>();
9 | countriesSet.add("Canada");
10 | countriesSet.add("Australia");
11 | countriesSet.add("Brazil");
12 | countriesSet.add("India");
13 | countriesSet.add("Japan");
14 | System.out.println(countriesSet);
15 |
16 | for (String country : countriesSet) {
17 | System.out.println(country);
18 | }
19 | }
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/src/main/java/org/class23/T3.java:
--------------------------------------------------------------------------------
1 | package org.class23;
2 |
3 | import java.util.LinkedHashSet;
4 | import java.util.Set;
5 |
6 | public class T3 {
7 | public static void main(String[] args) {
8 | Set city=new LinkedHashSet<>();
9 | city.add("Annapolis");
10 | city.add("New York");
11 | city.add("Ankara");
12 | city.add("Washington");
13 | city.add("Denver");
14 |
15 | city.removeIf(x->x.startsWith("A"));
16 |
17 | System.out.println(city);
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/org/class23/T4.java:
--------------------------------------------------------------------------------
1 | package org.class23;
2 |
3 | import java.util.HashSet;
4 |
5 | public class T4 {
6 | public static void main(String[] args) {
7 |
8 | HashSet students=new HashSet<>();
9 | students.add(new Student("Engin","123"));
10 | students.add(new Student("Kat","456"));
11 | students.add(new Student("Masimo","789"));
12 |
13 | for (Student s:students){
14 | s.printInfo();
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/class24/E2Maps.java:
--------------------------------------------------------------------------------
1 | package org.class24;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | public class E2Maps {
7 | public static void main(String[] args) {
8 |
9 | Map maps= new HashMap<>();
10 | maps.put("Apple",20);
11 | maps.put("Banana",15);
12 | maps.put("Kiwi",5);
13 | maps.put("Orange",20);
14 | System.out.println(maps);
15 | maps.remove("Kiwi");
16 | System.out.println(maps);
17 | maps.replace("Apple",30);
18 | System.out.println(maps);
19 | maps.clear();
20 | System.out.println(maps);
21 |
22 |
23 |
24 |
25 |
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/class24/E5Maps.java:
--------------------------------------------------------------------------------
1 | package org.class24;
2 |
3 | import org.class10.Dog;
4 |
5 | public class E5Maps {
6 | public static void main(String[] args) {
7 |
8 | String name="MyTeacher";
9 | var name1="Kawoon";
10 | int age=10;
11 | var age2=20;
12 | var d=new Dog();
13 |
14 |
15 |
16 |
17 |
18 |
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/org/class24/E8Maps.java:
--------------------------------------------------------------------------------
1 | package org.class24;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | public class E8Maps {
7 | public static void main(String[] args) {
8 |
9 | Map maps= new HashMap<>();
10 | maps.put("Apple",20);
11 | maps.put("Banana",15);
12 | maps.put("Kiwi",5);
13 | maps.put("Orange",20);
14 | maps.forEach((k,v)-> System.out.println(k+" "+v));
15 | System.out.println("****************");
16 | maps.forEach((k,v)-> {
17 | if(k.contains("A")||v>10){
18 | System.out.println(k+" "+v);
19 | }
20 | });
21 |
22 |
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/class24/E9AnaGram.java:
--------------------------------------------------------------------------------
1 | package org.class24;
2 |
3 | import java.util.Arrays;
4 |
5 | public class E9AnaGram {
6 | public static void main(String[] args) {
7 | String s1="silent";
8 | String s2="listen";
9 | char[] s1Arr=s1.toCharArray();
10 | char[] s2Arr=s2.toCharArray();
11 | Arrays.sort(s1Arr);
12 | Arrays.sort(s2Arr);
13 | System.out.println(Arrays.toString(s1Arr));
14 | System.out.println(Arrays.toString(s2Arr));
15 | //to check if arrays are equals
16 | System.out.println(Arrays.equals(s1Arr,s2Arr));
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/org/class24/Notes:
--------------------------------------------------------------------------------
1 | Maps:
2 |
--------------------------------------------------------------------------------
/src/main/java/org/class24/Person.java:
--------------------------------------------------------------------------------
1 | package org.class24;
2 |
3 | public class Person {
4 |
5 | private String name;
6 | private String lastName;
7 | private int age;
8 | private int salary;
9 |
10 | public Person(String name, String lastName, int age, int salary) {
11 | this.name = name;
12 | this.lastName = lastName;
13 | this.age = age;
14 | this.salary = salary;
15 | }
16 |
17 |
18 | public void printInfo(){
19 | System.out.println(name+" "+lastName+" "+age+" "+salary);
20 | }
21 | }
--------------------------------------------------------------------------------
/src/main/java/org/class24/T1.java:
--------------------------------------------------------------------------------
1 | package org.class24;
2 |
3 | import java.util.Map;
4 | import java.util.TreeMap;
5 |
6 | public class T1 {
7 | public static void main(String[] args) {
8 | Map maps=new TreeMap<>();
9 | maps.put("Afghanistan","kabul");
10 | maps.put("India","Delhi");
11 | maps.put("Pakistan","Islamabad");
12 | maps.put("Iran","Tehran");
13 | maps.put("France","PAris");
14 | maps.forEach((k,v)-> System.out.println(v));
15 | maps.forEach((k,v)-> System.out.println(k+" "+v));
16 | }
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/src/main/java/org/class24/Task2.java:
--------------------------------------------------------------------------------
1 | package org.class24;
2 |
3 | import java.util.TreeMap;
4 |
5 | public class Task2 {
6 | public static void main(String[] args) {
7 | TreeMap pers=new TreeMap<>();
8 | pers.put(1,new Person("Farid","F",25,3000));
9 | pers.put(2,new Person("Rauf","R",26,4000));
10 | pers.put(3,new Person("Alim","A",27,5000));
11 | pers.put(4,new Person("Yodgor","Y",28,6000));
12 | pers.forEach((key,personObj)->{
13 | System.out.println("id:"+key);
14 | personObj.printInfo();
15 | });
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/class24/Task3.java:
--------------------------------------------------------------------------------
1 | package org.class24;
2 |
3 | import java.util.LinkedHashMap;
4 | import java.util.Map;
5 |
6 | public class Task3 {
7 | public static void main(String[] args) {
8 | Map employee=new LinkedHashMap<>();
9 | employee.put("Samad",80000);
10 | employee.put("Amir",90000);
11 | employee.put("Amid",100000);
12 |
13 | String empName="";
14 | int salary=0;
15 |
16 | for (var e:employee.entrySet()){
17 | if(e.getValue()>salary){
18 | empName=e.getKey();
19 | salary=e.getValue();
20 | }
21 | }
22 | System.out.println(empName+" =$"+salary);
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/class25/E2FileHandling.java:
--------------------------------------------------------------------------------
1 | package org.class25;
2 |
3 | import org.utils.ConfigReader;
4 |
5 | import java.io.IOException;
6 |
7 | public class E2FileHandling {
8 | public static void main(String[] args) throws IOException {
9 |
10 | String value= ConfigReader.read("browser");
11 | System.out.println(value);
12 | // Break till 11:54
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/class25/E6NestedData.java:
--------------------------------------------------------------------------------
1 | package org.class25;
2 |
3 | import java.util.ArrayList;
4 |
5 | public class E6NestedData {
6 | public static void main(String[] args) {
7 |
8 | ArrayList> nestedArr=new ArrayList<>();
9 |
10 | ArrayList arr1=new ArrayList<>();
11 | arr1.add(10);
12 | arr1.add(12);
13 | arr1.add(15);
14 |
15 | ArrayList arr2=new ArrayList<>();
16 | arr2.add(5);
17 | arr2.add(3);
18 | arr2.add(2);
19 |
20 | nestedArr.add(arr1);
21 | nestedArr.add(arr2);
22 | System.out.println(nestedArr);
23 |
24 |
25 |
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/class25/E7NestedData.java:
--------------------------------------------------------------------------------
1 | package org.class25;
2 |
3 | import java.util.ArrayList;
4 | import java.util.LinkedHashMap;
5 | import java.util.Map;
6 |
7 | public class E7NestedData {
8 | public static void main(String[] args) {
9 |
10 | Map> map=new LinkedHashMap<>();
11 |
12 | ArrayList arr1=new ArrayList<>();
13 | arr1.add(10);
14 | arr1.add(12);
15 | arr1.add(15);
16 |
17 | ArrayList arr2=new ArrayList<>();
18 | arr2.add(5);
19 | arr2.add(3);
20 | arr2.add(2);
21 |
22 | map.put(1,arr1);
23 | map.put(2,arr2);
24 | System.out.println(map);
25 |
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/class25/Notes:
--------------------------------------------------------------------------------
1 | FileHandling:
2 | Its the process of reading and writing
3 | data to a file.
4 | If we want to read/write data to a file manually we need
5 | following:
6 | 1)Location of the file on the computer.
7 | 2) Navigate to the location.
8 | 3) A Special software that knows how to read/write
9 | data to that file must be installed on the computer.
10 | Steps to create a new folder in your project:
11 | 1) Right click on your project.
12 | 2) Click on new-> Directory
13 | 3) Give name and hit enter
--------------------------------------------------------------------------------
/src/main/java/org/class26/E5Exception.java:
--------------------------------------------------------------------------------
1 | package org.class26;
2 |
3 | public class E5Exception {
4 | public static void main(String[] args) {
5 | System.out.println(10/0);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/org/class26/E6Exception.java:
--------------------------------------------------------------------------------
1 | package org.class26;
2 |
3 | public class E6Exception {
4 | public static void main(String[] args) {
5 |
6 | int [] arr={10,20};
7 | System.out.println(arr[3]);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/org/class26/E7Exception.java:
--------------------------------------------------------------------------------
1 | package org.class26;
2 |
3 | public class E7Exception {
4 | public static void main(String[] args) {
5 |
6 | String name="My teacher";
7 | System.out.println(name.charAt(50));
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/org/class26/Notes.txt:
--------------------------------------------------------------------------------
1 | When we perform data driven testing. We need to read/write
2 | data in Excel files.
3 | What do we need to know for reading the data from any file?
4 | 1) we must know the location of the file.
5 | 2) we must know who to bring the dta from the file into
6 | the script/Java code.
7 | 3) we must have a class to manipulate the file.
8 | How to get the location of File in Intellij?
9 | To get location of File in Intellij we can right-click
10 | we can click on copy path reference.
11 |
--------------------------------------------------------------------------------
/src/main/java/org/class27/BankAccount.java:
--------------------------------------------------------------------------------
1 | package org.class27;
2 |
3 | public class BankAccount {
4 |
5 | private double funds;
6 | public BankAccount(double funds){
7 | this.funds=funds;
8 | }
9 | void transferFunds(double amountToTransfer){
10 |
11 | if(amountToTransfer>funds){
12 | throw new InsufficientFundsException("Not Enough funds in your account");
13 | //System.out.println("Not Enough funds in your account");
14 | }else{
15 | funds=funds-amountToTransfer;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/org/class27/BankTester.java:
--------------------------------------------------------------------------------
1 | package org.class27;
2 |
3 | public class BankTester {
4 | public static void main(String[] args) {
5 | BankAccount b=new BankAccount(100);
6 | b.transferFunds(120);
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/org/class27/E2Exception.java:
--------------------------------------------------------------------------------
1 | package org.class27;
2 |
3 | import java.io.FileInputStream;
4 | import java.io.FileNotFoundException;
5 |
6 | public class E2Exception {
7 | public static void main(String[] args) {
8 |
9 | int number1=10;
10 | int number2=0;
11 | System.out.println(number1/number2);
12 | // Break till 11:55
13 |
14 | try {
15 | FileInputStream fis=new FileInputStream("sbjsd");
16 | } catch (FileNotFoundException e) {
17 | throw new RuntimeException(e);
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/org/class27/E3Exception.java:
--------------------------------------------------------------------------------
1 | package org.class27;
2 |
3 | import java.util.Scanner;
4 |
5 | public class E3Exception {
6 | public static void main(String[] args) {
7 |
8 |
9 | Scanner scanner=new Scanner(System.in);
10 | System.out.println("Please Enter the numbers that you want to divide");
11 | int num1=scanner.nextInt();
12 | int num2=scanner.nextInt();
13 | if(num2==0){
14 | System.out.println("We can't divide b y zero");
15 | }else{
16 | System.out.println(num1/num2);
17 | }
18 |
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/org/class27/E4Exceptions.java:
--------------------------------------------------------------------------------
1 | package org.class27;
2 |
3 | import java.io.FileInputStream;
4 | import java.io.FileNotFoundException;
5 |
6 | public class E4Exceptions {
7 | public static void main(String[] args) {
8 |
9 | try {
10 | FileInputStream fis = new FileInputStream("C:\\Users\\Syntax\\IdeaProjects\\SDETJavaB18\\Files\\Batch18.xlsx");
11 | }catch (FileNotFoundException fis){
12 | System.out.println("Please check the file");
13 | }
14 |
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/org/class27/E5Exception.java:
--------------------------------------------------------------------------------
1 | package org.class27;
2 |
3 | import java.io.FileInputStream;
4 | import java.io.FileNotFoundException;
5 | import java.io.IOException;
6 |
7 | public class E5Exception {
8 | public static void main(String[] args) {
9 | FileInputStream fis=null;
10 | try {
11 | fis=new FileInputStream("C:\\Users\\Syntax\\IdeaProjects\\SDETJavaB18\\Files\\Batch18.xlsx");
12 |
13 | }catch (FileNotFoundException f){
14 | System.out.println("Please check the path");
15 | }finally {
16 | try {
17 | fis.close();
18 | } catch (IOException e) {
19 | System.out.println("Somewthing went wrong");
20 | }
21 | }
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/org/class27/E6Exception.java:
--------------------------------------------------------------------------------
1 | package org.class27;
2 |
3 | public class E6Exception {
4 | public static void main(String[] args) {
5 |
6 |
7 | System.out.println(1);
8 | try{
9 | System.out.println(2);
10 | // System.out.println(10/0);
11 | System.out.println(3);
12 | }catch (ArithmeticException e){
13 | System.out.println(4);
14 | // System.out.println(10/0);
15 | System.out.println(5);
16 | }finally {
17 | System.out.println(10/0);
18 | System.out.println("Will always be executed");
19 | }
20 | System.out.println(8);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/class27/E8Exception.java:
--------------------------------------------------------------------------------
1 | package org.class27;
2 |
3 | import java.io.FileInputStream;
4 | import java.io.IOException;
5 |
6 | public class E8Exception {
7 | public static void main(String[] args) {
8 |
9 | try(FileInputStream fis = new FileInputStream("C:\\Users\\Syntax\\IdeaProjects\\SDETJavaB18\\Files\\Batch18.xlsx")) {
10 |
11 | }catch (IOException e){
12 | System.out.println("Please check the file path");
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/org/class27/FileReader.java:
--------------------------------------------------------------------------------
1 | package org.class27;
2 |
3 | import java.io.FileInputStream;
4 | import java.io.FileNotFoundException;
5 |
6 | public class FileReader {
7 |
8 | static void readFile() throws FileNotFoundException {
9 | FileInputStream fileInputStream=new FileInputStream("C:\\Users\\Syntax\\IdeaProjects\\SDETJavaB18\\Files\\Batch18.xlsx");
10 | }
11 |
12 |
13 | public static void main(String[] args) {
14 | try{
15 | readFile();
16 | }catch (FileNotFoundException f){
17 | System.out.println("Please check the file path");
18 | }
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/class27/InsufficientFundsException.java:
--------------------------------------------------------------------------------
1 | package org.class27;
2 |
3 | public class InsufficientFundsException extends RuntimeException {
4 | /***
5 | * THis exception will be thrown whenever user tries to use more
6 | * funds than they have in their account.
7 | * @param msg
8 | */
9 | InsufficientFundsException(String msg){
10 | super(msg);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/org/class27/Notes.txt:
--------------------------------------------------------------------------------
1 | Exception:
2 | An unwanted behaviour which disrupts the normal
3 | flow of your program.
--------------------------------------------------------------------------------
/src/main/java/org/class3/E10IfElseStatement.java:
--------------------------------------------------------------------------------
1 | package org.class3;
2 |
3 | public class E10IfElseStatement {
4 | public static void main(String[] args) {
5 |
6 | int age=60;
7 | if (age>=60){
8 | System.out.println("You get 10% discount");
9 | }else{
10 | System.out.println("No discount for you");
11 | }
12 |
13 | int price=100;
14 | if(age>=60){
15 | price=price-10;
16 | }else{
17 | price=price;
18 | }
19 | System.out.println(price);
20 |
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/org/class3/E12IfElse.java:
--------------------------------------------------------------------------------
1 | package org.class3;
2 |
3 | public class E12IfElse {
4 | public static void main(String[] args) {
5 |
6 | String name="Karimi";
7 | /*
8 | whenever we have a non primtiive type we
9 | should never use == sign
10 | */
11 | if(!name.equals("Sino")){
12 | System.out.println("Fast");
13 | }else{
14 | System.out.println("Moderate");
15 | }
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/org/class3/E1ElseIfQuiz.java:
--------------------------------------------------------------------------------
1 | package org.class3;
2 |
3 | public class E1ElseIfQuiz {
4 |
5 |
6 | public static void main(String[] args) {
7 | int age=20;
8 |
9 | if(age<1){
10 | System.out.println("Baby");
11 | }else if(age <20){
12 | System.out.println("teenager");
13 | }else if(age <30){
14 | System.out.println("Still young");
15 | }else if (age<50){
16 | System.out.println("A little old");
17 | }else{
18 | System.out.println("Old");
19 | }
20 |
21 |
22 | // Break till 1:48
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/org/class3/E1TypeCasting.java:
--------------------------------------------------------------------------------
1 | package org.class3;
2 |
3 | public class E1TypeCasting {
4 |
5 | public static void main(String[] args) {
6 |
7 | int age=10;
8 | System.out.println(age);
9 | //moving smaller int box to a larger double box
10 | //thats why no issues
11 | double age2=age;
12 | System.out.println(age2);
13 |
14 | double largeBox=10.5;
15 | int smallBox=(int)largeBox;
16 | System.out.println(smallBox);
17 | short mediumBox=100;
18 | byte smallestBox=(byte)mediumBox;
19 | System.out.println(smallestBox);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/class3/E2TypeCasting.java:
--------------------------------------------------------------------------------
1 | package org.class3;
2 |
3 | import com.sun.tools.javac.Main;
4 |
5 | public class E2TypeCasting {
6 | public static void main(String[] args) {
7 | double price=12.3;
8 | double quantity=3;
9 | double totalPrice=price*quantity;
10 | // we can get rid of decimal part by
11 | // type casting
12 | System.out.println((int)totalPrice);
13 | }
14 |
15 |
16 |
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/org/class3/E3TypeCasting.java:
--------------------------------------------------------------------------------
1 | package org.class3;
2 |
3 | public class E3TypeCasting {
4 | public static void main(String[] args) {
5 | int num=10;
6 | int num2=num*20;
7 |
8 | double num3=num2/10;
9 | System.out.println(num3);
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/org/class3/E4TypeCastingQuiz.java:
--------------------------------------------------------------------------------
1 | package org.class3;
2 | /*
3 | Asghar 2
4 | Batch18 1
5 | */
6 | public class E4TypeCastingQuiz {
7 | public static void main(String[] args) {
8 |
9 |
10 | long box1=234;
11 | int box2=(int)box1;
12 | System.out.println(box2);
13 |
14 | short box3=1300;
15 | float box4=box3;
16 | System.out.println(box4);
17 |
18 |
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/org/class3/E5IfElseStatements.java:
--------------------------------------------------------------------------------
1 | package org.class3;
2 |
3 | public class E5IfElseStatements {
4 | public static void main(String[] args) {
5 |
6 | boolean isRaining=false;
7 |
8 | if(isRaining) {
9 | System.out.println("Take the umbrella");
10 | }
11 | System.out.println("Lets go shopping");
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/class3/E6IfElseStatement.java:
--------------------------------------------------------------------------------
1 | package org.class3;
2 |
3 | public class E6IfElseStatement {
4 | public static void main(String[] args) {
5 |
6 | int age=15;
7 |
8 | if(age<18){
9 | System.out.println("You can't vote");
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/org/class3/E7IfElseStatement.java:
--------------------------------------------------------------------------------
1 | package org.class3;
2 |
3 | public class E7IfElseStatement {
4 | public static void main(String[] args) {
5 |
6 | boolean isWifeAngry=false;
7 |
8 | if(isWifeAngry){
9 | System.out.println("Buy flowers ");
10 | System.out.println("Buy chocolates");
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/class3/E8IfElseStatement.java:
--------------------------------------------------------------------------------
1 | package org.class3;
2 |
3 | public class E8IfElseStatement {
4 | public static void main(String[] args) {
5 |
6 | int age=16;
7 | if(age>= 18){
8 | System.out.println("You can vote");
9 | }else{
10 | System.out.println("You can't vote");
11 | // break till 11:52
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/class3/E9RelationalOperator.java:
--------------------------------------------------------------------------------
1 | package org.class3;
2 |
3 | import java.sql.SQLOutput;
4 |
5 | public class E9RelationalOperator {
6 |
7 |
8 | public static void main(String[] args) {
9 |
10 | System.out.println(10>5); //true
11 | System.out.println(10>15); // false
12 | System.out.println(10>=15); // false or false -> false
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/class3/T1DoubleComparison.java:
--------------------------------------------------------------------------------
1 | package org.class3;
2 |
3 | /*
4 | Create a Java program and name it T1DoubleComparison.
5 | Declare 2 double variables and if value of first variable is
6 | higher then the second, print “Double value __ is larger
7 | than __ .”
8 | */
9 | public class T1DoubleComparison {
10 |
11 | public static void main(String[] args) {
12 | double num1=15;
13 | double num2=10.6;
14 | if(num1>num2){
15 | System.out.println("Double value "+num1+" is larger than "+num2);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/org/class3/T2TempCheck.java:
--------------------------------------------------------------------------------
1 | package org.class3;
2 | /*
3 | Create a Java program and name it Temperature Check.
4 | Create a variable to store temperature. Your program should check
5 | if temperature is below 32 then it should print “Water will freeze
6 | with temperature __”, otherwise “Water will NOT freeze with
7 | temperature __”.
8 | */
9 | public class T2TempCheck {
10 | public static void main(String[] args) {
11 | int temp=35;
12 | if(temp<32){
13 | System.out.println("Water will freeze with temperature "+temp);
14 | }else{
15 | System.out.println("Water will not freeze with temperature "+temp);
16 | }
17 | }
18 |
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/org/class3/T3.java:
--------------------------------------------------------------------------------
1 | package org.class3;
2 |
3 | /*
4 | 3. Create Java program to store 2 values for expected and actual hours.
5 | Your program should check
6 | if actual hours are more than expected the program should print
7 | “You will love the course and you will succeed”,
8 | otherwise “Course will be very hard for you!”
9 |
10 | */
11 | public class T3 {
12 | public static void main(String[] args) {
13 | int expectedHours=22;
14 | int actualHours=25;
15 | if(actualHours>expectedHours){
16 | System.out.println("You will love the course and you will succeed");
17 | }else{
18 | System.out.println("Course will be very hard for you!");
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/class3/T5.java:
--------------------------------------------------------------------------------
1 | package org.class3;
2 |
3 | /*
4 | Write a program to check whether number is positive or negative.
5 | */
6 | public class T5 {
7 | public static void main(String[] args) {
8 |
9 | int number=-10;
10 | if(number>0){
11 | System.out.println("Positive");
12 | }else if(number<0){
13 | System.out.println("Negative");
14 | }else{
15 | System.out.println("Zero");
16 | }
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/org/class3/T6.java:
--------------------------------------------------------------------------------
1 | package org.class3;
2 | /*
3 | Write a Java Program to check whether number is Even or Odd.
4 | */
5 | public class T6 {
6 | public static void main(String[] args) {
7 |
8 | int number=13;
9 |
10 | if(number%2==0){
11 | System.out.println(number+" is an even number");
12 | }else{
13 | System.out.println(number+" is odd");
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/org/class3/T7.java:
--------------------------------------------------------------------------------
1 | package org.class3;
2 |
3 | /*
4 | Basic Fare Calculator: Declare an integer variable
5 | age and set it to any value. Use if-else statements
6 | to determine a basic bus fare price: if the age is less
7 | than 13, the fare is $2; if the age is 13 or more, the
8 | fare is $5.
9 | */
10 | public class T7 {
11 | public static void main(String[] args) {
12 | int age=34;
13 |
14 | if(age<13){
15 | System.out.println("The fare is $2");
16 | }else{
17 | System.out.println("The fare is $5");
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/org/class3/T8.java:
--------------------------------------------------------------------------------
1 | package org.class3;
2 | /*
3 | Grade Message: Create a Java program with an
4 | integer variable testScore set to a value between
5 | 0 and 100. Use if-else statements to print "Pass"
6 | if the score is 50 or above, and "Fail" if it's below 50.
7 | */
8 | public class T8 {
9 |
10 | public static void main(String[] args) {
11 | int testScore=90;
12 |
13 | if(testScore>=50){
14 | System.out.println("Pass");
15 | }else{
16 | System.out.println("Fail");
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/org/class3/T9.java:
--------------------------------------------------------------------------------
1 | package org.class3;
2 | /*
3 | Traffic Light Actions: Declare a String variable
4 | trafficLight and set it to either "Red", "Yellow", or
5 | "Green". Use if-else statements to print "Stop" if the
6 | light is "Red", "Caution" if the light is "Yellow", and
7 | "Go" if the light is "Green"
8 | */
9 | public class T9 {
10 | public static void main(String[] args) {
11 |
12 | String trafficLight="Yellow";
13 |
14 | if(trafficLight.equals("Red")){
15 | System.out.println("Stop");
16 | }else if(trafficLight.equals("Yelllo")){
17 | System.out.println("Caution");
18 | } else if(trafficLight.equals("Green")){
19 | System.out.println("Go");
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/class4/E3Scanner.java:
--------------------------------------------------------------------------------
1 | package org.class4;
2 |
3 |
4 | import java.util.Scanner;
5 |
6 | public class E3Scanner {
7 | public static void main(String[] args) {
8 | System.out.println("Please Enter your age");
9 | /*
10 | Scanner is datatype
11 | scan is a variable
12 | new is a keyword that we use to create objects
13 | (System.in) means we want to read from keyboard
14 | */
15 | Scanner scan=new Scanner(System.in);
16 | //scan.nextInt() take the int number from the
17 | //keyboard ans store it inside age variable
18 | int age=scan.nextInt();
19 | System.out.println("You are "+age+" years old");
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/class4/E4Scanner.java:
--------------------------------------------------------------------------------
1 | package org.class4;
2 |
3 | import java.util.Scanner;
4 |
5 | public class E4Scanner {
6 | public static void main(String[] args) {
7 |
8 | System.out.println("Please Enter your name");
9 | Scanner fetchName= new Scanner(System.in);
10 | String name=fetchName.next();
11 |
12 | System.out.println("Your name is "+name);
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/org/class4/E5Scanner.java:
--------------------------------------------------------------------------------
1 | package org.class4;
2 |
3 | import java.util.Scanner;
4 |
5 | public class E5Scanner {
6 | public static void main(String[] args) {
7 |
8 | Scanner sc=new Scanner(System.in);
9 | System.out.println("Please Enter you full name");
10 | String fullName=sc.nextLine();
11 | System.out.println("Your Full Name is "+fullName);
12 |
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/class4/E6Scanner.java:
--------------------------------------------------------------------------------
1 | package org.class4;
2 |
3 | import java.util.Scanner;
4 |
5 | public class E6Scanner {
6 | public static void main(String[] args) {
7 |
8 | Scanner fetchWeight=new Scanner(System.in);
9 | System.out.println("Please enter your weight in lbs");
10 | double weight=fetchWeight.nextDouble();
11 | System.out.println("You have "+weight+" weight");
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/class4/E7Scanner.java:
--------------------------------------------------------------------------------
1 | package org.class4;
2 |
3 | import java.util.Scanner;
4 |
5 | public class E7Scanner {
6 | public static void main(String[] args) {
7 | Scanner sc=new Scanner(System.in);
8 | System.out.println("Please Enter your gender M/F");
9 | char gender=sc.next().charAt(0);
10 | System.out.println("Your gender is "+gender);
11 | // Break till 1:54
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/class4/Notes:
--------------------------------------------------------------------------------
1 | Nested If Else condition:
2 | Nested if conditions one condition inside another one.
3 | Why we need it?
4 | In real life many decisions are dependent on each other.
5 | if outer condition is not met it does not make sense to
6 | proceed with in the inner conditions.
7 | For example before we can place an order on a website
8 | we first want to make sure
9 | 1)User is logged-in
10 | 2) User has selected some products
11 | 3) Products are available in inventory
12 | 4) User selects a valid payment method
13 | 5) User has enough balance.
14 | 6) If all above conditions are met then only we want to
15 | place an order.
--------------------------------------------------------------------------------
/src/main/java/org/class4/ScannerIssues.java:
--------------------------------------------------------------------------------
1 | package org.class4;
2 |
3 | import java.util.Scanner;
4 |
5 | public class ScannerIssues {
6 | public static void main(String[] args) {
7 | System.out.println("Please Enter your age");
8 | Scanner sc=new Scanner(System.in);
9 | int age= sc.nextInt();
10 | System.out.println("Please Enter your full name");
11 | // its gonna comsume that enter press
12 | sc.nextLine();
13 | String fullName=sc.nextLine();
14 | System.out.println("Your name is "+fullName+" and you are "+age+" old");
15 |
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/class4/T1.java:
--------------------------------------------------------------------------------
1 | package org.class4;
2 |
3 | public class T1 {
4 | public static void main(String[] args) {
5 |
6 |
7 | double age = 25;
8 | double weight = 180;
9 |
10 | if (age >= 18) {
11 |
12 | if (weight >= 110) {
13 | System.out.println("You are eligible for blood donation");
14 | } else {
15 | System.out.println("You are not eligible for a blood donation");
16 | }
17 | }else {
18 | System.out.println("We cannot accept such patient");
19 | }
20 |
21 |
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/org/class4/T2.java:
--------------------------------------------------------------------------------
1 | package org.class4;
2 |
3 | public class T2 {
4 |
5 | public static void main(String[] args) {
6 | int num1=200,num2=400,num3=100;
7 |
8 | if(num1>num2){
9 |
10 | if(num1>num3){
11 | System.out.println("Num1 is largest "+num1);
12 | }else{
13 | System.out.println("Num3 is largest "+num3);
14 | }
15 |
16 | }else{
17 | if(num2>num3){
18 | System.out.println("Num2 is largest "+num2);
19 | }else{
20 | System.out.println("Num3 is largest "+num3);
21 | }
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/org/class4/T3.java:
--------------------------------------------------------------------------------
1 | package org.class4;
2 |
3 | import java.util.Scanner;
4 |
5 | /*
6 | You are a loan specialist and you need to ask
7 | user what is the amount of loan is needed.
8 | If loan is less or equal to 200,000 then you would
9 | lend the money otherwise you would reject the client.
10 | */
11 | public class T3 {
12 | public static void main(String[] args) {
13 | System.out.println("Please Enter the loan amount");
14 | Scanner sc=new Scanner(System.in);
15 | double loanAmount=sc.nextDouble();
16 | if(loanAmount<=200000){
17 | System.out.println("You can get this loan");
18 | }else{
19 | System.out.println("This amount can't be provided");
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/class4/T4.java:
--------------------------------------------------------------------------------
1 | package org.class4;
2 |
3 | import java.util.Scanner;
4 |
5 | /*
6 | You are DMV representative and
7 | you need to ask customer their age.
8 | If they are 18 or older you will
9 | issue a driver license to them,
10 | otherwise you will offer them to get a learners permit.
11 | */
12 | public class T4 {
13 | public static void main(String[] args) {
14 | Scanner sc=new Scanner(System.in);
15 | System.out.println("Please Enter your age");
16 | int age=sc.nextInt();
17 |
18 | if(age>=18){
19 | System.out.println("I will issue a driving license to you");
20 | }else{
21 | System.out.println("for now you can only have learners permit");
22 | }
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/class4/T5.java:
--------------------------------------------------------------------------------
1 | package org.class4;
2 |
3 | import java.util.Scanner;
4 |
5 | /*
6 | Create a Java program that will ask
7 | user to input city and temperature. Your program should
8 | convert Fahrenheit into celsius and print “The temperature
9 | is the city __ is __”
10 | */
11 | public class T5 {
12 | public static void main(String[] args) {
13 | Scanner sc=new Scanner(System.in);
14 | System.out.println("Please Enter your City");
15 | String city=sc.nextLine();
16 | System.out.println("Please Enter the temperature in F"+city);
17 | double temp=sc.nextDouble();
18 | double tempInCelsius=(temp-32)*5.0/9.0;
19 | System.out.println("Temperature in "+city+" is "+tempInCelsius+"C");
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/class5/E1LogicalOperators.java:
--------------------------------------------------------------------------------
1 | package org.class5;
2 |
3 | public class E1LogicalOperators {
4 | public static void main(String[] args) {
5 |
6 | boolean box=false;
7 | System.out.println(box);
8 | System.out.println(!box);
9 | System.out.println(box);
10 |
11 | if(!box){
12 | System.out.println("Inside if part");
13 | }else{
14 | System.out.println("inside else part");
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/class5/E2LogicalOperators.java:
--------------------------------------------------------------------------------
1 | package org.class5;
2 |
3 | public class E2LogicalOperators {
4 | public static void main(String[] args) {
5 | String country="UK";
6 |
7 | if(!country.equals("Iran")){
8 | System.out.println("You can visit the USA");
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/org/class5/E3LogicalOperators.java:
--------------------------------------------------------------------------------
1 | package org.class5;
2 |
3 | public class E3LogicalOperators {
4 | public static void main(String[] args) {
5 |
6 | boolean condition1=true;
7 | boolean condition2=false;
8 |
9 | if(!(condition1|| condition2)){
10 | System.out.println("If");
11 | }else{
12 | System.out.println("Else");
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/org/class5/E4LogicalOperators.java:
--------------------------------------------------------------------------------
1 | package org.class5;
2 |
3 | public class E4LogicalOperators {
4 | public static void main(String[] args) {
5 |
6 | boolean bringFlower=false;
7 | boolean bringChocolates=false;
8 | boolean allMyMistake=false;
9 |
10 | if(bringFlower||bringChocolates||allMyMistake){
11 | System.out.println("HomeMinister is Happy");
12 | }else{
13 | System.out.println("HomeMinister is angry");
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/org/class5/E5LogicalOperators.java:
--------------------------------------------------------------------------------
1 | package org.class5;
2 |
3 | public class E5LogicalOperators {
4 | public static void main(String[] args) {
5 |
6 | boolean is4GAvbl=false;
7 | boolean isWifiAvbl=false;
8 |
9 | if(isWifiAvbl||is4GAvbl){
10 | System.out.println("You can browse the internet");
11 | }else{
12 | System.out.println("Can't use internet");
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/org/class5/E6LogicalAND.java:
--------------------------------------------------------------------------------
1 | package org.class5;
2 |
3 | public class E6LogicalAND {
4 | public static void main(String[] args) {
5 |
6 | boolean cond1=true;
7 | boolean cond2=true;
8 | boolean cond3=true;
9 |
10 | if(cond1&&cond2&& cond3){
11 | System.out.println("If");
12 | }else {
13 | System.out.println("Else");
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/org/class5/StringMethodDemo.java:
--------------------------------------------------------------------------------
1 | package org.class5;
2 |
3 | public class StringMethodDemo {
4 | public static void main(String[] args) {
5 |
6 | String name="ALADIN";
7 | System.out.println(name.toLowerCase());
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/E10ForLoop.java:
--------------------------------------------------------------------------------
1 | package org.class6;
2 |
3 | public class E10ForLoop {
4 | public static void main(String[] args) {
5 | /*
6 | Print even numbers from 20 to 100
7 | Expected output 20 22 24 26….. 100
8 | */
9 | for(int i=20;i<=100;i=i+2){
10 | System.out.print(i+" ");
11 | }
12 |
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/E11ForLoop.java:
--------------------------------------------------------------------------------
1 | package org.class6;
2 |
3 | public class E11ForLoop {
4 | public static void main(String[] args) {
5 | /*
6 | Print only odd numbers from 100 to 1
7 | Expected output
8 | 99 97 95 93….1
9 | */
10 | for(int i=99;i>=1;i=i-2){
11 | System.out.print(i+" ");
12 | }
13 | // break 1:49
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/E12ScannerAndLoop.java:
--------------------------------------------------------------------------------
1 | package org.class6;
2 |
3 | import java.util.Scanner;
4 |
5 | public class E12ScannerAndLoop {
6 |
7 | public static void main(String[] args) {
8 |
9 | Scanner sc=new Scanner(System.in);
10 | System.out.println("Please enter the starting point");
11 | int start=sc.nextInt();
12 | System.out.println("Please Enter the end");
13 | int end=sc.nextInt();
14 | System.out.println("Please Enter the step size as well");
15 | int step=sc.nextInt();
16 | while(start<=end){
17 | System.out.print(start+" ");
18 | start=start+step;
19 | }
20 |
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/E1loop.java:
--------------------------------------------------------------------------------
1 | package org.class6;
2 |
3 | public class E1loop {
4 | public static void main(String[] args) {
5 |
6 | int i=1;
7 | while(i<=5){
8 | System.out.println("Hello Batch 18");
9 |
10 | i=i+1;
11 | }
12 |
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/E2Loop.java:
--------------------------------------------------------------------------------
1 | package org.class6;
2 |
3 | public class E2Loop {
4 | public static void main(String[] args) {
5 |
6 | int i=12;
7 |
8 | i--;
9 | System.out.println(i);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/E3Loop.java:
--------------------------------------------------------------------------------
1 | package org.class6;
2 |
3 | public class E3Loop {
4 | public static void main(String[] args) {
5 |
6 | int i=1;
7 |
8 | while(i<=4){
9 | System.out.println(i);
10 | i++; // increase the value of i by 1
11 | }
12 |
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/E4loop.java:
--------------------------------------------------------------------------------
1 | package org.class6;
2 |
3 | public class E4loop {
4 | public static void main(String[] args) {
5 |
6 | int x=1;
7 | // first conditions is checked if conditions is true we enter the loop
8 | while(x<=5){
9 | if(x!=2){ // first instruction is if statement if it is true print statement is executed
10 | System.out.println(x);
11 | }
12 | x++; // increments the value of the x by one every time it is executed.
13 | // break till 11:49
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/E5Loop.java:
--------------------------------------------------------------------------------
1 | package org.class6;
2 |
3 | public class E5Loop {
4 | public static void main(String[] args) {
5 |
6 | int i=1;
7 |
8 | do{
9 | System.out.println(i);
10 | i++;
11 | }while (i<=5);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/E6Loop.java:
--------------------------------------------------------------------------------
1 | package org.class6;
2 |
3 | /*
4 | Print numbers from 100 to 1
5 | Expected output 100 99 98 97 …..1
6 |
7 | */
8 | public class E6Loop {
9 | public static void main(String[] args) {
10 | int i=100;
11 |
12 | do{
13 | System.out.print(i+" ");
14 | i--;
15 | }while(i>=1);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/E7Loop.java:
--------------------------------------------------------------------------------
1 | package org.class6;
2 | /*
3 | Print even numbers from 20 to 100
4 | Expected output 20 22 24 26….. 100
5 |
6 | */
7 | public class E7Loop {
8 | public static void main(String[] args) {
9 |
10 | int i=20;
11 |
12 | do{
13 | System.out.print(i+" ");
14 | i=i+2;
15 | }while (i<=100);
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/E8Loop.java:
--------------------------------------------------------------------------------
1 | package org.class6;
2 |
3 | public class E8Loop {
4 | public static void main(String[] args) {
5 |
6 | for(int i=1;i<=10;i++){
7 | System.out.print(i+" ");
8 | }
9 |
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/E9ForLoop.java:
--------------------------------------------------------------------------------
1 | package org.class6;
2 | /*
3 | Print numbers from 100 to 1
4 | Expected output 100 99 98 97 …..1
5 |
6 | */
7 | public class E9ForLoop {
8 | public static void main(String[] args) {
9 |
10 | for(int i=100;i>=1;i--){
11 | System.out.print(i+" ");
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/T1.java:
--------------------------------------------------------------------------------
1 | package org.class6;
2 |
3 | public class T1 {
4 | // print numbers from 11 to 20 by writing a loop
5 | public static void main(String[] args) {
6 |
7 | int i=11;
8 |
9 | while(i<=20){
10 | System.out.print(i+" ");
11 | i++;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/T2.java:
--------------------------------------------------------------------------------
1 | package org.class6;
2 |
3 | public class T2 {
4 | //write a loop to print 5 4 3 2 1
5 | public static void main(String[] args) {
6 |
7 | int i=5;
8 | while(i>=1){
9 | System.out.print(i+" ");
10 | i--;
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/T3.java:
--------------------------------------------------------------------------------
1 | package org.class6;
2 | /*
3 | Print numbers from 100 to 1
4 | Expected output 100 99 98 97 …..1
5 |
6 | */
7 | public class T3 {
8 | public static void main(String[] args) {
9 | int y=100;
10 | while(y>=1){
11 | System.out.print(y+" ");
12 | y--;
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/T4.java:
--------------------------------------------------------------------------------
1 | package org.class6;
2 | /*
3 | Print even numbers from 20 to 100
4 | Expected output 20 22 24 26….. 100
5 |
6 | */
7 | public class T4 {
8 | public static void main(String[] args) {
9 |
10 | int i=20;
11 | while(i<=100){
12 | System.out.print(i+" ");
13 | i=i+2;// increments the value of the i by 23
14 | }
15 | System.out.println();
16 | int y=20;
17 | while (y<=100){
18 |
19 | if(y%2==0){
20 | System.out.print(y+" ");
21 | }
22 | y++;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/T5.java:
--------------------------------------------------------------------------------
1 | package org.class6;
2 |
3 | /*
4 | Print only odd numbers from 99 to 1
5 | Expected output
6 | 99 97 95 93….1
7 |
8 | */
9 | public class T5 {
10 | public static void main(String[] args) {
11 | int i=99;
12 | while(i>=1){
13 | System.out.print(i+" ");
14 | i=i-2;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/T6.java:
--------------------------------------------------------------------------------
1 | package org.class6;
2 |
3 | public class T6 {
4 | /*
5 | Print even numbers from 20 to 1 (using 2 different loops)
6 | */
7 | public static void main(String[] args) {
8 |
9 | for(int i=20; i>=1;i=i-2){
10 | System.out.print(i+" ");
11 | }
12 | System.out.println();
13 | int j=20;
14 | while(j>=1){
15 | System.out.print(j+" ");
16 | j=j-2;
17 | }
18 |
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/T7.java:
--------------------------------------------------------------------------------
1 | package org.class6;
2 |
3 | public class T7 {
4 | public static void main(String[] args) {
5 | /*
6 | Print odd numbers between 20 and 50 (using 2 different loops)
7 | */
8 |
9 | for(int i=20;i<=50;i++){
10 | if(i%2!=0){
11 | System.out.print(i+" ");
12 | }
13 | }
14 | System.out.println();
15 | int i=20;
16 | while (i<=50) {
17 | if(i%2!=0){
18 | System.out.print(i+" ");
19 | }
20 | i++;
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/T8.java:
--------------------------------------------------------------------------------
1 | package org.class6;
2 |
3 | public class T8 {
4 | public static void main(String[] args) {
5 | //write a loop to add first 10 numbers from
6 | //1 to 10 =1+2+3+4+5+6+7+8+9+10=55
7 | int sum=0;
8 | int i=1;
9 | while (i<=10) {
10 | sum=sum+i;
11 | i++;
12 | }
13 | System.out.println(sum);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/org/class6/notes.txt:
--------------------------------------------------------------------------------
1 | Loops:
2 | Loop allows us to repeat a piece of code
3 | again and again until and condition fails.
4 |
--------------------------------------------------------------------------------
/src/main/java/org/class7/E10Arrays.java:
--------------------------------------------------------------------------------
1 | package org.class7;
2 |
3 | public class E10Arrays {
4 | public static void main(String[] args) {
5 | int [] numbers={10,25,44,33,56};
6 |
7 | /*System.out.println(numbers[0]);
8 | System.out.println(numbers[1]);
9 | System.out.println(numbers[2]);
10 | System.out.println(numbers[3]);
11 | System.out.println(numbers[4]);*/
12 |
13 | for(int i=0;i<5;i++){
14 | System.out.println(numbers[i]);
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/class7/E11Arrays.java:
--------------------------------------------------------------------------------
1 | package org.class7;
2 |
3 | public class E11Arrays {
4 | public static void main(String[] args) {
5 | int [] numbers={10,25,44,33,56};
6 | // modify this code to add all of the numbers from array
7 | int sum=0;
8 | for(int i=0;i<5;i++){
9 | sum=sum+numbers[i];
10 | }
11 | System.out.println(sum);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/class7/E12Arrays.java:
--------------------------------------------------------------------------------
1 | package org.class7;
2 |
3 | public class E12Arrays {
4 | public static void main(String[] args) {
5 | int [] numbers={10,20,30,45,69,55,45,69,20};
6 | //this is how we can get the size of the array
7 | System.out.println(numbers.length);
8 |
9 | for(int i=0; i=0; i--) {
10 | System.out.print(word[i]+" ");
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/class8/T1.java:
--------------------------------------------------------------------------------
1 | package org.class8;
2 |
3 | public class T1 {
4 | public static void main(String[] args) {
5 | String[] names={"Aidos","Zeeshan","Abid","Sharif","Zeeshan"};
6 | //Write a program to count how many times the name Zeeshan as
7 | //appeared in this array
8 | int count=0;
9 | for (int i = 0; i < names.length; i++) {
10 | if(names[i].equals("Zeeshan")){
11 | count++;
12 | }
13 | }
14 | System.out.println("Zeeshan appeared "+count+" times");
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/org/class8/T2.java:
--------------------------------------------------------------------------------
1 | package org.class8;
2 |
3 | public class T2 {
4 | public static void main(String[] args) {
5 |
6 | int [] numbers={10,15,20,18,9,60,22,30};
7 | // show the sum of even numbers and odd numbers
8 | //separately
9 | int sumOdd=0,sumEven=0;
10 | for(int num:numbers){
11 |
12 | if(num%2==0){
13 | sumEven=sumEven+num;
14 | }else{
15 | sumOdd=sumOdd+num;
16 | }
17 | }
18 | System.out.println("Sum of Even Numbers is "+sumEven);
19 | System.out.println("Sum of Odd Numbers is "+sumOdd);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/class8/T3.java:
--------------------------------------------------------------------------------
1 | package org.class8;
2 |
3 | public class T3 {
4 | public static void main(String[] args) {
5 | //
6 | int [] numbers={101,100,25,30,25,50,300};
7 | // to count how many numbers are divisible by
8 | // 5 and how many are divisible by 2
9 | // break till 1:56
10 | int n5=0,n2=0;
11 | for(int x:numbers){
12 | if(x%5==0){
13 | n5++;
14 | }
15 | if(x%2==0){
16 | n2++;
17 | }
18 | }
19 | System.out.println("Numbers divisible by 5 are "+n5);
20 | System.out.println("Numbers divisible by 2 are "+n2);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/class8/T4.java:
--------------------------------------------------------------------------------
1 | package org.class8;
2 |
3 | public class T4 {
4 | public static void main(String[] args) {
5 | // int [] numbers={10,15,20,18,9,60,22,30};
6 | int [] numbers={9,10,15,18,20,22,30,60};
7 | // print true if array is sorted otherwise print false
8 |
9 | boolean isSorted=true;
10 |
11 | for (int i = 0; i < numbers.length-1; i++) {
12 | if(numbers[i]>numbers[i+1]){
13 | isSorted=false;
14 | break;
15 | }
16 | }
17 | System.out.println("Is loop sorted "+isSorted);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/org/class9/E2Arrays.java:
--------------------------------------------------------------------------------
1 | package org.class9;
2 |
3 | public class E2Arrays {
4 | public static void main(String[] args) {
5 | int[][] matrix={
6 | {10,20,50},
7 | {25,35,66},
8 | {80,90,78,45},
9 | {45,55,66}
10 | };
11 |
12 | System.out.println(matrix[1][1]); //35
13 | System.out.println(matrix[0][2]); //50
14 | System.out.println(matrix[3][2]); //66
15 | // System.out.println(matrix[0][3]); //Error
16 | //gives number of rows
17 | System.out.println(matrix.length); //4
18 | System.out.println(matrix[0].length); //3
19 | System.out.println(matrix[2].length); //4
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/class9/E3Arrays.java:
--------------------------------------------------------------------------------
1 | package org.class9;
2 |
3 | public class E3Arrays {
4 | public static void main(String[] args) {
5 | int[][] matrix={
6 | {10,20,50},
7 | {25,35,66},
8 | {80,90,78,45},
9 | {45,55,66}
10 | };
11 |
12 | // break till 11:52AM EST
13 | int [] row=matrix[2];
14 | System.out.println(row[2]);//78
15 | for(int i=0;i25) {
23 | String str="Java";
24 | System.out.println(this.str);
25 | }
26 | }
27 | public static void main(String[] args) {
28 |
29 |
30 |
31 |
32 |
33 |
34 | }
35 |
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/interview/Notes:
--------------------------------------------------------------------------------
1 | git commit -m "Msg"
2 | 8:02
--------------------------------------------------------------------------------
/src/main/java/org/interview/PrintNumbers.java:
--------------------------------------------------------------------------------
1 | package org.interview;
2 |
3 | public class PrintNumbers {
4 |
5 |
6 | public static void main(String[] args) {
7 | printNumbers(1);
8 | }
9 |
10 |
11 | public static void printNumbers(int number) {
12 | if (number <= 100) {
13 | System.out.println(number);
14 | printNumbers(number + 1); // recursive call with incremented number
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/project2/Max.java:
--------------------------------------------------------------------------------
1 | package org.project2;
2 |
3 | public class Max {
4 | public static void main(String[] args) {
5 | String str= "hello";
6 | String reverse= "";
7 | for (int i = 0; i < str.length(); i++) {
8 | reverse = str.charAt(i)+reverse;
9 | }
10 | System.out.println(reverse);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/org/project2/Q1.java:
--------------------------------------------------------------------------------
1 | package org.project2;
2 |
3 | public class Q1 {
4 | public static void main(String[] args) {
5 | String a="Hello";
6 | String b="World";
7 | System.out.println("Before a= "+a+" b= "+b);
8 | a=a+b; //HelloWorld
9 | //10-5=5
10 | int endIndex=a.length()-b.length();
11 | b=a.substring(0,endIndex);
12 | a=a.substring(b.length());
13 | System.out.println("After a= "+a+" b= "+b);
14 |
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/org/project2/Q2.java:
--------------------------------------------------------------------------------
1 | package org.project2;
2 | /*
3 | /*2. Find out how many alpha characters are present in a string?
4 | */
5 | public class Q2 {
6 | public static void main(String[] args) {
7 | String str="7623467kdsnfskjdASDSJD!#@$#";
8 | System.out.println(str.replaceAll("[^a-zA-Z0-9]","").length());
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/project2/Q3.java:
--------------------------------------------------------------------------------
1 | package org.project2;
2 |
3 | /*
4 | Reverse a String: Write a function to reverse a given string.
5 | For example, given the input "Hello", the output should be "olleH"
6 | */
7 | public class Q3 {
8 | public static void main(String[] args) {
9 |
10 | String str="Hello";
11 | String newStr="";
12 | for (int i = str.length()-1; i >=0 ; i--) {
13 | newStr=newStr+str.charAt(i);
14 | }
15 | System.out.println(newStr);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/project2/Q4.java:
--------------------------------------------------------------------------------
1 | package org.project2;
2 |
3 | /*
4 | Check if a String is Palindrome: Determine whether a given string is a
5 | palindrome, which means it reads the same forwards and backward.
6 | For example, "madam" is a palindrome
7 | */
8 | public class Q4 {
9 | public static void main(String[] args) {
10 |
11 | String str="mam";
12 |
13 | System.out.println(str.equals(reverse(str)));
14 | }
15 |
16 | public static String reverse(String str){
17 |
18 | String newStr="";
19 | for (int i = str.length()-1; i >=0 ; i--) {
20 | newStr=newStr+str.charAt(i);
21 | }
22 | return newStr;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/org/project2/Q6.java:
--------------------------------------------------------------------------------
1 | package org.project2;
2 | /*6. Create a method to count how many vowels are present in a string
3 | “documentation”*/
4 | public class Q6 {
5 | public static void main(String[] args) {
6 |
7 | String str="documentation";
8 | System.out.println(str.replaceAll("[^aeiouAEIOU]","").length());
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/project2/Q7.java:
--------------------------------------------------------------------------------
1 | package org.project2;
2 | /*7. Count the Number of Words in a String: Write a function to count the
3 | number of words in a given string. Words are separated by spaces or
4 | punctuation. For example, the input "Hello, world!" should return 2.*/
5 | public class Q7 {
6 | public static void main(String[] args) {
7 |
8 | String str="Hello, world!";
9 | System.out.println(str.split(" ").length);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/org/review1/E1Variables.java:
--------------------------------------------------------------------------------
1 | package org.review1;
2 |
3 | public class E1Variables {
4 | public static void main(String[] args) {
5 | int age=10;
6 | System.out.println(age);
7 | age=20;
8 | System.out.println();
9 | System.out.print(age);
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/org/review1/E2Variables.java:
--------------------------------------------------------------------------------
1 | package org.review1;
2 |
3 | // camel case first letter of each word is uppercase
4 | public class E2Variables {
5 |
6 | public static void main(String[] args) {
7 | int age1=10,age2=20,age3=30;
8 | // Pascal case first letter is lowercase
9 | //after that every first letter of each word is uppercase
10 | int dogAge=12;
11 | // the results will be 60
12 | /*
13 |
14 | */
15 |
16 | age3=age3+age1+age2;
17 | System.out.println(age3);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/org/review1/E3StringConcat.java:
--------------------------------------------------------------------------------
1 | package org.review1;
2 |
3 | public class E3StringConcat {
4 |
5 | public static void main(String[] args) {
6 | String houseNo="H#295";
7 | String streetNo="Abc123";
8 | String state="New York";
9 | String country="USA";
10 | String space=" ";
11 | String completeAddress=houseNo+space+streetNo+space+state+space+country;
12 | System.out.println(houseNo+" "+streetNo+" "+state+" "+country);
13 | System.out.println(completeAddress);
14 |
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/org/review1/E4StringConcat.java:
--------------------------------------------------------------------------------
1 | package org.review1;
2 |
3 | public class E4StringConcat {
4 | public static void main(String[] args) {
5 | int houseNo=298;
6 | String street="abc street";
7 | System.out.println(houseNo+street);
8 | boolean isPresent=false;
9 | System.out.println(street+isPresent);
10 | }}
11 |
12 |
--------------------------------------------------------------------------------
/src/main/java/org/review1/E5Arithmetic.java:
--------------------------------------------------------------------------------
1 | package org.review1;
2 |
3 | public class E5Arithmetic {
4 | public static void main(String[] args) {
5 | int num1=20;
6 | int num2=10;
7 | //Addition
8 | System.out.println(num1+num2); //30
9 | //Subtraction
10 | System.out.println(num1-num2); //10
11 | //multiplication
12 | System.out.println(num1*num2); //200
13 | //division
14 | System.out.println(num1/num2); //2
15 | //Modulus
16 | System.out.println(num1%num2);
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/org/review1/E6ShortHand.java:
--------------------------------------------------------------------------------
1 | package org.review1;
2 |
3 | public class E6ShortHand {
4 | public static void main(String[] args) {
5 | int num=10;
6 | // addition and assignment
7 | //num=num+20;
8 | num+=20;
9 | System.out.println(num);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/org/review10/BankTester.java:
--------------------------------------------------------------------------------
1 | package org.review10;
2 |
3 | public class BankTester {
4 | public static void main(String[] args) {
5 |
6 | BankAccount b=new BankAccount(1200,"Username123","Pass123");
7 |
8 | b.setBalance(4500);
9 | System.out.println(b.getBalance());
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/org/review10/E2ArrayList.java:
--------------------------------------------------------------------------------
1 | package org.review10;
2 |
3 | import java.util.ArrayList;
4 |
5 | public class E2ArrayList {
6 | public static void main(String[] args) {
7 |
8 |
9 | ArrayList numbers=new ArrayList<>();
10 | numbers.add(15.0);
11 | numbers.add(25.0);
12 | numbers.add(35.5);
13 | numbers.add(40.5);
14 | numbers.add(50.0);
15 | System.out.println(numbers);
16 | //numbers.remove(0);
17 | numbers.remove(25.0);
18 | System.out.println(numbers);
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/review10/Notes:
--------------------------------------------------------------------------------
1 | Encapsulation:
2 | It helps us write more secure and manageable code.
3 | Collections Framework:
4 | Collections framework is simply a collection of classes which
5 | help us manage and manipulate large amounts of data.
6 | .
7 | Why We need Collections Framework?
8 | 1) We can't use arrays always as they are fixe in size.
9 | 2) Arrays don't have built-in methods.
10 |
11 | ArrayList:
12 |
13 |
--------------------------------------------------------------------------------
/src/main/java/org/review11/E1ArrayListVsLinkedList.java:
--------------------------------------------------------------------------------
1 | package org.review11;
2 |
3 | import java.util.LinkedList;
4 |
5 | public class E1ArrayListVsLinkedList {
6 | public static void main(String[] args) {
7 | long startTime=System.currentTimeMillis();
8 | LinkedList numbers=new LinkedList<>();
9 | for (int i = 0; i <1000000 ; i++) {
10 | numbers.add(0,i);
11 | }
12 |
13 | long endTime=System.currentTimeMillis();
14 | System.out.println(endTime-startTime);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/org/review11/E2Maps.java:
--------------------------------------------------------------------------------
1 | package org.review11;
2 |
3 | import java.util.ArrayList;
4 | import java.util.LinkedHashMap;
5 |
6 | public class E2Maps {
7 | public static void main(String[] args) {
8 |
9 |
10 | LinkedHashMap studentsMap=new LinkedHashMap<>();
11 | studentsMap.put("John",95);
12 | studentsMap.put("Adam",88);
13 | studentsMap.put("Muh",92);
14 | studentsMap.put("Kat",91);
15 | studentsMap.put("Kari",90);
16 | System.out.println(studentsMap);
17 | ArrayList names=new ArrayList<>();
18 | studentsMap.forEach((k, v)->{
19 | if(v>90)
20 | names.add(k);
21 | });
22 | System.out.println(names);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/org/review11/E3Maps.java:
--------------------------------------------------------------------------------
1 | package org.review11;
2 |
3 | import java.util.LinkedHashMap;
4 |
5 | public class E3Maps {
6 | public static void main(String[] args) {
7 |
8 |
9 | LinkedHashMap studentsMap=new LinkedHashMap<>();
10 | studentsMap.put("John",95);
11 | studentsMap.put("Adam",88);
12 | studentsMap.put("Muh",92);
13 | studentsMap.put("Kat",91);
14 | studentsMap.put("Kari",90);
15 | //if the name of the student contains the letter a or if marks are less than 90 remove those
16 | studentsMap.entrySet().removeIf(x->x.getValue()<=90||x.getKey().contains("a"));
17 | System.out.println(studentsMap);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/org/review11/E4Stream.java:
--------------------------------------------------------------------------------
1 | package org.review11;
2 |
3 | import java.util.Arrays;
4 |
5 | public class E4Stream {
6 | public static void main(String[] args) {
7 | int[] arr={10,20,30,40,5};
8 | int min= Arrays.stream(arr).min().getAsInt();
9 | int sum= Arrays.stream(arr).sum();
10 | System.out.println(min);
11 | System.out.println(sum);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/review11/E5Files.java:
--------------------------------------------------------------------------------
1 | package org.review11;
2 |
3 | import java.io.FileInputStream;
4 | import java.io.IOException;
5 | import java.util.Properties;
6 |
7 | public class E5Files {
8 | public static void main(String[] args) throws IOException {
9 | //Location
10 | String path="C:\\Users\\Syntax\\IdeaProjects\\SDETJavaB18\\Files\\Config.properties";
11 | //Bringing the file to the Memory(RAM)
12 | FileInputStream nato=new FileInputStream(path);
13 |
14 | Properties properties=new Properties();
15 | properties.load(nato);
16 | System.out.println(properties.getProperty("url"));
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/org/review11/E6Files.java:
--------------------------------------------------------------------------------
1 | package org.review11;
2 |
3 | import org.utils.ConfigReader;
4 |
5 | import java.io.IOException;
6 |
7 | public class E6Files {
8 | public static void main(String[] args) throws IOException {
9 |
10 | String browser= ConfigReader.read("browser");
11 | System.out.println(browser);
12 |
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/org/review11/E7Files.java:
--------------------------------------------------------------------------------
1 | package org.review11;
2 |
3 | public class E7Files {
4 | public static void main(String[] args) {
5 |
6 | String firstPart=System.getProperty("user.dir");
7 | System.out.println(firstPart);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/org/review11/Quiz.java:
--------------------------------------------------------------------------------
1 | package org.review11;
2 |
3 | import java.util.TreeSet;
4 |
5 | public class Quiz {
6 |
7 | public static void main(String[] args) {
8 | TreeSet map = new TreeSet();
9 | map.add("one");
10 | map.add("two");
11 | map.add("three");
12 | map.add("four");
13 | map.add("one");
14 | map.forEach(x-> System.out.println(x));
15 | // Break till 8:52
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/review12/BrainNotFound.java:
--------------------------------------------------------------------------------
1 | package org.review12;
2 |
3 | public class BrainNotFound extends RuntimeException{
4 |
5 | /***
6 | * Whenever we have to solve a homework or when we are
7 | * in the mock interviews that's where this exception occurs
8 | * @param errorMsg whenever this exception is thrown if we
9 | * want to pass an error msg that's when we
10 | * will be using this param.
11 | */
12 | BrainNotFound(String errorMsg){
13 | super(errorMsg);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/org/review12/E1Exception.java:
--------------------------------------------------------------------------------
1 | package org.review12;
2 |
3 | public class E1Exception {
4 |
5 | public static void main(String[] args) {
6 | int number=10;
7 | int [] arr=new int[2];
8 | arr[5]=10;
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/review12/E2Exception.java:
--------------------------------------------------------------------------------
1 | package org.review12;
2 |
3 | public class E2Exception {
4 |
5 | public static void main(String[] args) {
6 | int number=10;
7 | System.out.println(1);
8 | System.out.println(2);
9 | try{
10 | int [] arr=new int[2];
11 | arr[5]=10;
12 | }
13 |
14 | catch (ArrayIndexOutOfBoundsException a){
15 | a.printStackTrace();
16 | // System.out.println(a);
17 | // System.out.println(a.getMessage());
18 | }
19 | System.out.println(3);
20 |
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/org/review12/E3Exception.java:
--------------------------------------------------------------------------------
1 | package org.review12;
2 |
3 | public class E3Exception {
4 | public static void main(String[] args) {
5 | System.out.println(1);
6 | System.out.println(2);
7 | try {
8 | System.out.println(10/0);
9 | int [] arr=new int[2];
10 | arr[5]=10;
11 | }
12 | catch (ArrayIndexOutOfBoundsException a)
13 | {
14 | a.printStackTrace();
15 | }catch (ArithmeticException a){
16 | a.printStackTrace();
17 | }catch (Exception e){
18 | e.printStackTrace();
19 | }
20 | System.out.println(3);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/review12/E4Exception.java:
--------------------------------------------------------------------------------
1 | package org.review12;
2 |
3 | public class E4Exception {
4 | public static void main(String[] args) {
5 | System.out.println(1);
6 | System.out.println(2);
7 | try {
8 | System.out.println(10/0);
9 | int [] arr=new int[2];
10 | arr[5]=10;
11 | }
12 | catch (ArrayIndexOutOfBoundsException a)
13 | {
14 | a.printStackTrace();
15 | }catch (ArithmeticException a){
16 | a.printStackTrace();
17 | }catch (Exception e){
18 | e.printStackTrace();
19 | }finally {
20 |
21 | System.out.println("Will always be executed");
22 |
23 | System.out.println(3);
24 | }}
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/review12/Notes.txt:
--------------------------------------------------------------------------------
1 | Exception:
2 | It's an abnormal behaviour. that occurs
3 | during the execution of program. The
4 | program stops working, and we have to restart it.
5 | How can we solve these exception:
6 | We can read the error from bottom locate
7 | and then using the exception that we are
8 | getting we can look at the class to read more
9 | about that error.
10 |
--------------------------------------------------------------------------------
/src/main/java/org/review12/Tester.java:
--------------------------------------------------------------------------------
1 | package org.review12;
2 |
3 | public class Tester {
4 | public static void main(String[] args) {
5 |
6 | BrainNotFound brainNotFound=new BrainNotFound("Please make sure You have your brain");
7 | throw brainNotFound;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/org/review2/AnotherNestedIf.java:
--------------------------------------------------------------------------------
1 | package org.review2;
2 |
3 | public class AnotherNestedIf {
4 |
5 | public static void main(String[] args) {
6 |
7 | boolean isFriday=true;
8 | int day=13;
9 |
10 | if(isFriday) {
11 |
12 | System.out.println("It is a movie night");
13 |
14 | if(day==13){
15 | System.out.println("Let's watch a scary movie");
16 | }else {
17 | System.out.println("Let's watch something funny");
18 | }
19 |
20 | }else {
21 | System.out.println("No movies, go back to studies");
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/org/review2/ElseBlock.java:
--------------------------------------------------------------------------------
1 | package org.review2;
2 |
3 | public class ElseBlock {
4 |
5 | public static void main(String[] args) {
6 |
7 | int temp=91;
8 |
9 | if(temp>97) {
10 | System.out.println("I will go to the beach");
11 | } else { //otherwise
12 | System.out.println("I will stay at home and practice Java");
13 | }
14 |
15 | //////////////////////////////////////////////////////////
16 |
17 | String month="November";
18 |
19 | if (month.equals("November")) {
20 | System.out.println("It is Thanksgiving holiday");
21 | } else {
22 | System.out.println("There are holidays");
23 | }
24 |
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/org/review2/Recap.java:
--------------------------------------------------------------------------------
1 | package org.review2;
2 |
3 | public class Recap {
4 |
5 | public static void main(String[] args) {
6 |
7 | //Casting: widening/implicit & narrowing/explicit
8 | //byte->short->int->long->float->double
9 | double price =12;
10 | System.out.println(price); //12.00
11 |
12 | // narrowing: double-> float->long->int->short->byte
13 | int num=(int)12.99;
14 | System.out.println(num); //12
15 |
16 | double result=12/7; //1
17 | System.out.println(result);//1.0
18 |
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/org/review2/RelationalOperators.java:
--------------------------------------------------------------------------------
1 | package org.review2;
2 |
3 | public class RelationalOperators {
4 |
5 | public static void main(String[] args) {
6 |
7 | // >, >=, <, <=, ==, !=
8 | System.out.println(2<1);
9 |
10 | int temp=91;
11 |
12 | if(temp>90) {
13 | System.out.println("I will go to the beach");
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/org/review3/LogicalAnd.java:
--------------------------------------------------------------------------------
1 | package org.review3;
2 |
3 | public class LogicalAnd {
4 |
5 | //for logical && - All condition needs to be true to get a TRUE
6 | public static void main(String[] args) {
7 |
8 | boolean rain=false;
9 | boolean cold =true;
10 |
11 | if(cold && rain){
12 | System.out.println("I am staying home");
13 | }
14 |
15 | boolean messageDisplayed =true;
16 | String errorMessage ="Invalid credentials";
17 |
18 | if (messageDisplayed && errorMessage.equals("Invalid Credentials")){
19 | System.out.println("Test Case passed");
20 | }else {
21 | System.out.println("Test Case failed");
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/org/review3/LogicalNot.java:
--------------------------------------------------------------------------------
1 | package org.review3;
2 |
3 | public class LogicalNot {
4 |
5 | public static void main(String[] args) {
6 |
7 | boolean hungry=!true;
8 |
9 | System.out.println(hungry);
10 |
11 |
12 | boolean agreeCheckbox=false;
13 |
14 | if(!agreeCheckbox) {
15 | System.out.println("I will click on checkbox to select it");
16 | } else {
17 | System.out.println("I am not clicking on checkbox");
18 | }
19 |
20 | System.out.println("Clicking on Submit Payment");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/review3/LogicalOr.java:
--------------------------------------------------------------------------------
1 | package org.review3;
2 |
3 | public class LogicalOr {
4 |
5 | public static void main(String[] args) {
6 |
7 | boolean rain=false;
8 | boolean cold =true;
9 |
10 | if(cold || rain){
11 | System.out.println("I am staying home");
12 | }
13 |
14 | String welcomeMessage="Welcome Admin";
15 | boolean dashboardFormDisplayed=false;
16 |
17 | if(welcomeMessage.equals("Welcome Admin") || dashboardFormDisplayed) {
18 | System.out.println("Admin user is successfully logged in");
19 | } else {
20 | System.out.println("Cannot login using admin credentials");
21 | }
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/org/review3/SwitchAgain.java:
--------------------------------------------------------------------------------
1 | package org.review3;
2 |
3 | public class SwitchAgain {
4 |
5 | public static void main(String[] args) {
6 |
7 | char choice='Y';
8 |
9 | switch(choice) {
10 |
11 | case 'y': // this logical operator won't work || 'Y'
12 | System.out.println("Means Yes");
13 | break;
14 | case 'n':
15 | System.out.println("Means no");
16 | break;
17 | case 'm':
18 | System.out.println("Means Maybe");
19 | break;
20 | default:
21 | System.out.println("I do not understand you");
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/org/review4/WhileLoop.java:
--------------------------------------------------------------------------------
1 | package org.review4;
2 |
3 | public class WhileLoop {
4 |
5 | public static void main(String[] args) {
6 |
7 | //while - when we do NOT know in advance
8 | // how many times we want to repeat block of code
9 |
10 | // I want to say hello 4 times
11 | int n=1;
12 |
13 | while(n<=4) {
14 | System.out.println("Hello");
15 | n++;
16 | }
17 |
18 | /*
19 |
20 | while(data is there) {
21 |
22 | fetch data
23 | }
24 | */
25 |
26 |
27 |
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/org/review5/E10ArraysScanner.java:
--------------------------------------------------------------------------------
1 | package org.review5;
2 |
3 | import java.util.Arrays;
4 | import java.util.Scanner;
5 |
6 | public class E10ArraysScanner {
7 | public static void main(String[] args) {
8 | Scanner sc=new Scanner(System.in);
9 | System.out.println("Please Enter the size of the Array");
10 | int size=sc.nextInt();
11 | int [] numbers=new int[size];
12 | System.out.println(numbers.length);
13 |
14 | for (int i = 0; i < numbers.length; i++) {
15 | System.out.println("Please Enter the number "+(i+1));
16 | numbers[i]=sc.nextInt();
17 | }
18 |
19 | System.out.println(Arrays.toString(numbers));
20 |
21 |
22 |
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/review5/E1Arrays.java:
--------------------------------------------------------------------------------
1 | package org.review5;
2 |
3 | public class E1Arrays {
4 | public static void main(String[] args) {
5 |
6 | int [] arr=new int[100];
7 | arr[0]=10;
8 | arr[1]=12;
9 | arr[2]=20;
10 | for (int i = 0; i < arr.length; i++) {
11 | System.out.print(arr[i]+" ");
12 | }
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/org/review5/E2Arrays.java:
--------------------------------------------------------------------------------
1 | package org.review5;
2 |
3 | public class E2Arrays {
4 | public static void main(String[] args) {
5 | // Creating the array and initializing it
6 | int [] numbers={10,25,36,56,80};
7 | System.out.println(numbers.length);
8 | System.out.println(numbers[1]);
9 | for (int i = 0; i < numbers.length/2; i++) {
10 | System.out.print(numbers[i]+" ");
11 | }
12 | System.out.println();
13 | for(int n:numbers){
14 | System.out.print(n+" ");
15 | }
16 |
17 |
18 |
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/review5/E3Arrays.java:
--------------------------------------------------------------------------------
1 | package org.review5;
2 |
3 | public class E3Arrays {
4 | public static void main(String[] args) {
5 |
6 | int [] numbers={10,25,36,56,80,50,60};
7 |
8 | for (int i = 0; i < numbers.length; i=i+2) {
9 | System.out.println(numbers[i]);
10 | }
11 | for(int n:numbers){
12 | System.out.println(n);}
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/org/review5/E4Arrays.java:
--------------------------------------------------------------------------------
1 | package org.review5;
2 |
3 | public class E4Arrays {
4 | public static void main(String[] args) {
5 |
6 | String [] students=new String[5];
7 | students[0]="Kendi";
8 | students[1]="Adam";
9 | students[2]="John";
10 | students[3]="Ali";
11 | students[4]="Sino";
12 |
13 | for (int i = 0; i < students.length; i++) {
14 | System.out.print(students[i]+" ");
15 | }
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/org/review5/E5Arrays.java:
--------------------------------------------------------------------------------
1 | package org.review5;
2 |
3 | public class E5Arrays {
4 | public static void main(String[] args) {
5 |
6 | String [] students=new String[5];
7 | students[0]="Kendi";
8 | students[1]="Adam";
9 | students[2]="John";
10 | students[3]="Ali";
11 | students[4]="Sino";
12 |
13 | for (int i = 0; i < students.length; i++) {
14 |
15 | if(students[i].equals("John")){
16 | students[i]="Good Student";
17 | }
18 | }
19 |
20 | for (int i = 0; i < students.length; i++) {
21 | System.out.println(students[i]);
22 | }
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/review5/E6Arrays.java:
--------------------------------------------------------------------------------
1 | package org.review5;
2 |
3 | import java.util.Arrays;
4 |
5 | public class E6Arrays {
6 | public static void main(String[] args) {
7 |
8 | String [] students=new String[5];
9 | students[0]="Kendi";
10 | students[1]="Adam";
11 | students[2]="John";
12 | students[3]="Ali";
13 | students[4]="Sino";
14 |
15 | for (int i = 0; i < students.length; i++) {
16 |
17 | if(students[i].equals("John")){
18 | students[i]="Good Student";
19 | }
20 | }
21 | // If you just want to print the items in a row from array we can use this.
22 | System.out.println(Arrays.toString(students));
23 | // 8:52
24 |
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/org/review5/E7Arrays.java:
--------------------------------------------------------------------------------
1 | package org.review5;
2 |
3 | public class E7Arrays {
4 | public static void main(String[] args) {
5 | int [] numbers={10,25,36,56,80};
6 | //iter
7 | for (int number : numbers) {
8 | System.out.println(number);
9 | }
10 |
11 | //for i
12 | for (int i = 0; i < numbers.length; i++) {
13 | System.out.println(numbers[i]);
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/org/review5/E8D2Array.java:
--------------------------------------------------------------------------------
1 | package org.review5;
2 |
3 | public class E8D2Array {
4 | public static void main(String[] args) {
5 |
6 | int [][] numbers={
7 | {10,20,30,40},
8 | {20,40,60,80},
9 | {30,60,90,120}
10 | };
11 | //geetting back complete 1d array from 2D array
12 | int[] row0 = numbers[0];
13 | // Getting back individual number from 2D Array
14 | int num=numbers[2][2];
15 | System.out.println(num);
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/org/review5/E9D2Array.java:
--------------------------------------------------------------------------------
1 | package org.review5;
2 |
3 | public class E9D2Array {
4 | public static void main(String[] args) {
5 |
6 | double [][] numbers={
7 | {10,20,30,40},
8 | {20,40,60,80,100},
9 | {30,60,90}
10 | };
11 |
12 | System.out.println(numbers.length);
13 | System.out.println(numbers[1].length);
14 | for (int i = 0; i < numbers.length; i++) {
15 | for (int j = 0; j < numbers[i].length; j++) {
16 | System.out.print(numbers[i][j]+" ");
17 | }
18 | System.out.println();
19 |
20 | }
21 |
22 |
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/review6/Crow.java:
--------------------------------------------------------------------------------
1 | package org.review6;
2 |
3 | import org.review7.Bird;
4 |
5 | public class Crow extends Bird {
6 | void printInfo(){
7 | System.out.println(color);
8 | }
9 |
10 | }
11 |
12 | class Sparrow{
13 | void printInfo(){
14 | System.out.println();
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/review6/E10StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.review6;
2 |
3 | public class E10StringDemo {
4 | public static void main(String[] args) {
5 | String str="java";
6 | System.out.println(str.indexOf('a'));
7 | System.out.println(str.lastIndexOf('a'));
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/org/review6/E11StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.review6;
2 |
3 | public class E11StringDemo {
4 | public static void main(String[] args) {
5 | String str="java is easy JK";
6 | System.out.println(str.substring(0,4));
7 |
8 |
9 |
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/org/review6/E12StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.review6;
2 |
3 | public class E12StringDemo {
4 | public static void main(String[] args) {
5 | String str="My name is James my Number is 91245687";
6 | String str2="My name is James my Number is 91245687";
7 | String str3="My name is James my Number is 91245687";
8 |
9 | String number=str.replaceAll("[^0-9]","");
10 | System.out.println(number);
11 | StringBuilder stringBuilder=new StringBuilder("Java");
12 | System.out.println(stringBuilder);
13 |
14 |
15 |
16 |
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/org/review6/E1StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.review6;
2 |
3 | public class E1StringDemo {
4 | public static void main(String[] args) {
5 |
6 | String str= new String("Java ");
7 | System.out.println(str.length());
8 | int len=str.length();
9 | System.out.println(len);
10 |
11 |
12 |
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/org/review6/E2StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.review6;
2 |
3 | public class E2StringDemo {
4 | public static void main(String[] args) {
5 |
6 | String str=" ";
7 | System.out.println(str.isEmpty());
8 | System.out.println(str.isBlank());
9 |
10 | //str.isEmpty().isBlank();
11 | boolean r=str.isEmpty();
12 | // r.isblank;
13 | int number=10;
14 | // number.isEmpty();
15 |
16 |
17 | String str2="Java ";
18 | str2.trim().isBlank();
19 |
20 |
21 |
22 |
23 |
24 |
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/org/review6/E3StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.review6;
2 |
3 | public class E3StringDemo {
4 | public static void main(String[] args) {
5 |
6 | String str=" JAVA IS LOVE ";
7 |
8 | System.out.println(str.toLowerCase().trim().length());
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/review6/E4StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.review6;
2 |
3 | public class E4StringDemo {
4 | public static void main(String[] args) {
5 |
6 | String str="051-1542-454512";
7 | if(str.startsWith("347")){
8 | System.out.println("Number is from New York");
9 | }
10 | System.out.println(str.endsWith("12"));
11 | String sentence;
12 | //Break till 8:49
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/org/review6/E5StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.review6;
2 |
3 | public class E5StringDemo {
4 | public static void main(String[] args) {
5 | String str="Today is a JAVA review class";
6 | System.out.println(str.contains("c"));
7 | str.toLowerCase().contains("java");
8 |
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/review6/E6StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.review6;
2 |
3 | public class E6StringDemo {
4 | public static void main(String[] args) {
5 | String str="Today is a JAVA review class";
6 | System.out.println(str.charAt(4));
7 | // convert the letters to lowercase
8 | str=str.toLowerCase();
9 | int counter=0;
10 | for (int i = 0; i < str.length(); i++) {
11 | if(str.charAt(i)=='a'){
12 | counter++;
13 | }
14 | }
15 | System.out.println("Letter a appeared "+counter+" times");
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/review6/E7StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.review6;
2 |
3 | public class E7StringDemo {
4 | public static void main(String[] args) {
5 | System.out.println(Character.isUpperCase('A'));
6 | System.out.println(Character.isLowerCase('D'));
7 | System.out.println(Character.isDigit('r'));
8 | System.out.println(Character.isAlphabetic('5'));
9 |
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/org/review6/E8StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.review6;
2 |
3 | public class E8StringDemo {
4 | public static void main(String[] args) {
5 | String str="this one should be false";
6 | System.out.println(str.indexOf('o'));
7 | System.out.println(str.indexOf("one"));
8 | System.out.println(str.indexOf("is"));
9 | System.out.println(str.indexOf("z"));
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/org/review6/E9StringDemo.java:
--------------------------------------------------------------------------------
1 | package org.review6;
2 |
3 | public class E9StringDemo {
4 | public static void main(String[] args) {
5 | String str="this one should be false";
6 | System.out.println(str.indexOf('o'));
7 | System.out.println(str.lastIndexOf('o'));
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/org/review6/Person.java:
--------------------------------------------------------------------------------
1 | package org.review6;
2 |
3 | public class Person {
4 | String name;
5 | int age;
6 | double weight;
7 | double height;
8 |
9 | void eat(){
10 | System.out.println("Eating .....");
11 | }
12 |
13 | String getName(){
14 | return name;
15 | }
16 |
17 | public static void main(String[] args) {
18 | Person p= new Person();
19 | p.name="Karimi Naughty";
20 | p.age=22;
21 | p.height=5.4;
22 | p.weight=120;
23 | System.out.println(p.name);
24 | p.eat();
25 | String n=p.getName();
26 | System.out.println(n);
27 |
28 |
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/review7/Bird.java:
--------------------------------------------------------------------------------
1 | package org.review7;
2 |
3 | public class Bird {
4 | String name;
5 | protected String color;
6 | public int age;
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/org/review7/Cat.java:
--------------------------------------------------------------------------------
1 | package org.review7;
2 |
3 | public class Cat {
4 | private String name;
5 | String color;
6 |
7 | public int age;
8 |
9 | void printName(){
10 | System.out.println(name);
11 |
12 | }
13 |
14 | public static void main(String[] args) {
15 | Cat c=new Cat();
16 | c.name="kitti";
17 | c.color="black";
18 | c.age=15;
19 | }
20 | }
21 |
22 | class CatTester{
23 | public static void main(String[] args) {
24 | Cat c=new Cat();
25 | c.color="White";
26 | c.age=20;
27 |
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/review7/DogTester.java:
--------------------------------------------------------------------------------
1 | package org.review7;
2 |
3 | public class DogTester {
4 | public static void main(String[] args) {
5 |
6 | Dog d1=new Dog("jacky","Black",5,45);
7 | d1.printInfo();
8 | Dog d2=new Dog("lulu","White",7,20);
9 | d1.printInfo();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/org/review7/E1.java:
--------------------------------------------------------------------------------
1 | package org.review7;
2 | /*
3 | Create a method which will take an array of ints as
4 | input and going to return the sum of all the numbers
5 | from the input array
6 | */
7 | public class E1 {
8 |
9 | public static int arr(int[] number) {
10 | int sum = 0;
11 | for (int i = 0; i < number.length; i++) {
12 | sum = sum + number[i];
13 |
14 | }
15 | System.out.println(sum);
16 | return sum;
17 |
18 | }
19 |
20 | public static void main(String[] args) {
21 |
22 | int [] ar= new int[]{10,20,56};
23 |
24 | System.out.println( arr(ar));
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/org/review7/E1Method.java:
--------------------------------------------------------------------------------
1 | package org.review7;
2 |
3 | public class E1Method {
4 | void print(){
5 | System.out.println("Hello There");
6 | }
7 | public static void main(String[] args) {
8 | // new E1Method().print();
9 | E1Method e1 =new E1Method();
10 | e1.print();
11 | String str=new String("Java");
12 |
13 | System.out.println( str.toLowerCase());
14 | }
15 |
16 |
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/org/review7/E2TypesOfVariables.java:
--------------------------------------------------------------------------------
1 | package org.review7;
2 |
3 | public class E2TypesOfVariables {
4 |
5 | public static void main(String[] args) {
6 |
7 | /*
8 | local variable
9 | */
10 |
11 | if(10>5){
12 | int sum=0;
13 | }
14 | // Can't be used outside of the block they are created
15 | //System.out.println(sum);
16 | for (int i = 0; i < 10; i++) {
17 | String name="Jinko";
18 | }
19 |
20 | double weight=23;
21 | // break till 8:53
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/org/review7/MathTester.java:
--------------------------------------------------------------------------------
1 | package org.review7;
2 |
3 | public class MathTester {
4 | public static void main(String[] args) {
5 | Printer p=new Printer();
6 | p.printHello();
7 | Math m=new Math();
8 | int result= m.add(10,20);
9 | int avg=result/2;
10 | String str="java";
11 |
12 | int len=str.length();
13 | if(len>4){
14 | System.out.println("Word accepted");
15 | }
16 | for (int i = 0; i < str.length(); i++) {
17 |
18 | }
19 | if(str.isBlank()){
20 |
21 | }
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/org/review7/Printer.java:
--------------------------------------------------------------------------------
1 | package org.review7;
2 |
3 | public class Printer {
4 |
5 | void printHello(){
6 | System.out.println("Hello World");
7 | }
8 | }
9 |
10 | class Math{
11 |
12 | int add(int num1,int num2){
13 | return num1+num2;
14 | }
15 |
16 |
17 | }
--------------------------------------------------------------------------------
/src/main/java/org/review7/Tester.java:
--------------------------------------------------------------------------------
1 | package org.review7;
2 |
3 | public class Tester {
4 | public static void main(String[] args) {
5 | Cat c=new Cat();
6 | c.color="Blue";
7 | //c.name="private";
8 | c.age=45;
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/review8/Stadium.java:
--------------------------------------------------------------------------------
1 | package org.review8;
2 |
3 | public class Stadium {
4 |
5 | public static void main(String[] args) {
6 |
7 | Sport sport=new Sport("Soccer", "Man City");
8 | System.out.println(sport.type +" and team name is "+sport.teamName);
9 | System.out.println(sport.numberOfPlayers);
10 |
11 | Sport sport1=new Sport("Basketball", "Chicago Bulls", 15, "Chicago", "Billy Donovan");
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/review8_1/Orthodontist.java:
--------------------------------------------------------------------------------
1 | package org.review8_1;
2 |
3 | import org.review8.Doctor;
4 |
5 | public class Orthodontist extends Doctor {
6 |
7 | public Orthodontist(String firstName, String lastName, String speciality, int yearsOfExperience){
8 | super(firstName, lastName, speciality, yearsOfExperience);
9 | }
10 |
11 | public void printSpeciality(){
12 | System.out.println("I am "+speciality);
13 | }
14 |
15 | public void prescribeMedication(String medication){
16 | System.out.println(speciality+" prescribes special medication "+medication);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/org/review9/CarTester.java:
--------------------------------------------------------------------------------
1 | package org.review9;
2 |
3 | public class CarTester {
4 | public static void main(String[] args) {
5 | Car c=new Car();
6 | c.trust();
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/org/review9/PolyTester.java:
--------------------------------------------------------------------------------
1 | package org.review9;
2 |
3 | public class PolyTester {
4 | public static void main(String[] args) {
5 |
6 | Dog d=new Dog("Jacky","Black",1,"German");
7 | Cat c=new Cat("Mano","White",5);
8 |
9 | Animal [] animals={d,c};
10 | for(Animal a:animals){
11 | a.eat();
12 | a.speak();
13 | a.printInfo();
14 | System.out.println(a.getName());
15 | /* if(a instanceof Dog){
16 | Dog d2=(Dog)a;
17 | d2.run();
18 | }*/
19 |
20 | }
21 | //Upcasting
22 | /* Animal a=animals[1];
23 | //((Dog)a).run();
24 | Dog d2=(Dog)a;
25 | d2.run();*/
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/utils/Constants.java:
--------------------------------------------------------------------------------
1 | package org.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\\Batch18.xlsx";
6 |
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/src/main/java/org/utils/Test.java:
--------------------------------------------------------------------------------
1 | package org.utils;
2 |
3 | import java.io.FileInputStream;
4 | import java.io.IOException;
5 | import java.util.Properties;
6 |
7 | public class Test {
8 | public static String read(String key,String path) {
9 |
10 | Properties properties=new Properties();
11 | FileInputStream fis=null;
12 |
13 | try {
14 | fis=new FileInputStream(path);
15 | properties.load(fis);
16 | } catch (IOException e) {
17 | throw new RuntimeException(e);
18 | }
19 | return properties.getProperty(key);
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------