├── .DS_Store
├── .classpath
├── .project
├── .settings
└── org.eclipse.jdt.core.prefs
├── bin
└── com
│ ├── .DS_Store
│ ├── review01
│ ├── IfElseDemo.class
│ ├── MathTask.class
│ ├── PrintDemo.class
│ ├── ScannerDemo.class
│ ├── ScannerTask.class
│ ├── TypeConversion.class
│ └── VariableDemo.class
│ ├── review02
│ ├── AndOperatorRichBoy.class
│ ├── CalculatorHW.class
│ ├── IfElseIfMonth.class
│ ├── LoopsIntro.class
│ ├── NestedIfBuyCar.class
│ ├── NestedIfCardBalance.class
│ ├── NestedIfRichBoy.class
│ ├── NestedIfWeather.class
│ ├── Operators.class
│ ├── SingleGuy.class
│ ├── SwitchCapitalCity.class
│ ├── SwitchLevel.class
│ └── SwitchMonth.class
│ ├── review03
│ ├── ContinueDemo.class
│ ├── DoWhileDemo.class
│ ├── ScannerLoop.class
│ ├── SumEvenForLoop.class
│ ├── SumEvenWhile.class
│ ├── Task1.class
│ └── WhileDemo.class
│ ├── review04
│ ├── ArrayDemo.class
│ ├── ArrayMaxMin.class
│ ├── ScannerArray.class
│ ├── StringArrayScannerDemo.class
│ └── TwoDArrayDemo.class
│ ├── review05
│ ├── Q6.class
│ ├── Q7.class
│ ├── StringManipulation.class
│ ├── TwoDArrayDemo.class
│ ├── TwoDArrayEnhanced.class
│ ├── TwoDArraySumEachRow.class
│ └── TwoDArraySumMinMax.class
│ ├── review06
│ ├── ArrayManipulation.class
│ ├── Baby.class
│ ├── FamilyDemo.class
│ ├── JamesMember.class
│ ├── MathOperation.class
│ ├── School.class
│ └── World.class
│ ├── review07
│ ├── Addition.class
│ ├── Dermatologist.class
│ ├── Doctor.class
│ └── HospitalApplication.class
│ ├── review08
│ ├── .DS_Store
│ ├── Abstraction
│ │ ├── Belarusian.class
│ │ ├── Human.class
│ │ ├── Turkish.class
│ │ └── World.class
│ ├── Abstraction2
│ │ ├── Apple.class
│ │ ├── Crackable.class
│ │ ├── Fruit.class
│ │ ├── FruitDemo.class
│ │ ├── Orange.class
│ │ ├── Peelable.class
│ │ ├── Walnut.class
│ │ └── Washable.class
│ └── Polymorphism
│ │ ├── Belarusian.class
│ │ ├── Human.class
│ │ ├── Turkish.class
│ │ └── World.class
│ ├── review09
│ ├── CollectionIntro.class
│ ├── Phone.class
│ ├── PhoneDemo.class
│ └── WrapperDemo.class
│ ├── review10
│ ├── MapIntro.class
│ ├── SetIntro.class
│ └── WorldMap.class
│ └── review11
│ ├── ExcelDemo.class
│ ├── ExcelMap.class
│ └── PropertiesDemo.class
├── extra
├── Excel.xlsx
└── demo.properties
└── src
└── com
├── .DS_Store
├── review01
├── IfElseDemo.java
├── MathTask.java
├── PrintDemo.java
├── ScannerDemo.java
├── ScannerTask.java
├── TypeConversion.java
└── VariableDemo.java
├── review02
├── AndOperatorRichBoy.java
├── CalculatorHW.java
├── IfElseIfMonth.java
├── LoopsIntro.java
├── NestedIfBuyCar.java
├── NestedIfCardBalance.java
├── NestedIfRichBoy.java
├── NestedIfWeather.java
├── Operators.java
├── SingleGuy.java
├── SwitchCapitalCity.java
├── SwitchLevel.java
└── SwitchMonth.java
├── review03
├── ContinueDemo.java
├── DoWhileDemo.java
├── ScannerLoop.java
├── SumEvenForLoop.java
├── SumEvenWhile.java
├── Task1.java
└── WhileDemo.java
├── review04
├── ArrayDemo.java
├── ArrayMaxMin.java
├── ScannerArray.java
├── StringArrayScannerDemo.java
└── TwoDArrayDemo.java
├── review05
├── Q6.java
├── Q7.java
├── StringManipulation.java
├── TwoDArrayDemo.java
├── TwoDArrayEnhanced.java
├── TwoDArraySumEachRow.java
└── TwoDArraySumMinMax.java
├── review06
├── ArrayManipulation.java
├── Baby.java
├── FamilyDemo.java
├── JamesMember.java
├── MathOperation.java
├── School.java
└── World.java
├── review07
├── Addition.java
├── Dermatologist.java
├── Doctor.java
└── HospitalApplication.java
├── review08
├── .DS_Store
├── Abstraction
│ ├── Belarusian.java
│ ├── Human.java
│ ├── Turkish.java
│ └── World.java
├── Abstraction2
│ ├── Apple.java
│ ├── Crackable.java
│ ├── Fruit.java
│ ├── FruitDemo.java
│ ├── Orange.java
│ ├── Peelable.java
│ ├── Walnut.java
│ └── Washable.java
└── Polymorphism
│ ├── Belarusian.java
│ ├── Human.java
│ ├── Turkish.java
│ └── World.java
├── review09
├── CollectionIntro.java
├── Phone.java
├── PhoneDemo.java
└── WrapperDemo.java
├── review10
├── MapIntro.java
├── SetIntro.java
└── WorldMap.java
└── review11
├── ExcelDemo.java
├── ExcelMap.java
└── PropertiesDemo.java
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/.DS_Store
--------------------------------------------------------------------------------
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | JavaReviewBatch6
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=1.8
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11 | org.eclipse.jdt.core.compiler.source=1.8
12 |
--------------------------------------------------------------------------------
/bin/com/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/.DS_Store
--------------------------------------------------------------------------------
/bin/com/review01/IfElseDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review01/IfElseDemo.class
--------------------------------------------------------------------------------
/bin/com/review01/MathTask.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review01/MathTask.class
--------------------------------------------------------------------------------
/bin/com/review01/PrintDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review01/PrintDemo.class
--------------------------------------------------------------------------------
/bin/com/review01/ScannerDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review01/ScannerDemo.class
--------------------------------------------------------------------------------
/bin/com/review01/ScannerTask.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review01/ScannerTask.class
--------------------------------------------------------------------------------
/bin/com/review01/TypeConversion.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review01/TypeConversion.class
--------------------------------------------------------------------------------
/bin/com/review01/VariableDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review01/VariableDemo.class
--------------------------------------------------------------------------------
/bin/com/review02/AndOperatorRichBoy.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review02/AndOperatorRichBoy.class
--------------------------------------------------------------------------------
/bin/com/review02/CalculatorHW.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review02/CalculatorHW.class
--------------------------------------------------------------------------------
/bin/com/review02/IfElseIfMonth.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review02/IfElseIfMonth.class
--------------------------------------------------------------------------------
/bin/com/review02/LoopsIntro.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review02/LoopsIntro.class
--------------------------------------------------------------------------------
/bin/com/review02/NestedIfBuyCar.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review02/NestedIfBuyCar.class
--------------------------------------------------------------------------------
/bin/com/review02/NestedIfCardBalance.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review02/NestedIfCardBalance.class
--------------------------------------------------------------------------------
/bin/com/review02/NestedIfRichBoy.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review02/NestedIfRichBoy.class
--------------------------------------------------------------------------------
/bin/com/review02/NestedIfWeather.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review02/NestedIfWeather.class
--------------------------------------------------------------------------------
/bin/com/review02/Operators.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review02/Operators.class
--------------------------------------------------------------------------------
/bin/com/review02/SingleGuy.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review02/SingleGuy.class
--------------------------------------------------------------------------------
/bin/com/review02/SwitchCapitalCity.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review02/SwitchCapitalCity.class
--------------------------------------------------------------------------------
/bin/com/review02/SwitchLevel.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review02/SwitchLevel.class
--------------------------------------------------------------------------------
/bin/com/review02/SwitchMonth.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review02/SwitchMonth.class
--------------------------------------------------------------------------------
/bin/com/review03/ContinueDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review03/ContinueDemo.class
--------------------------------------------------------------------------------
/bin/com/review03/DoWhileDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review03/DoWhileDemo.class
--------------------------------------------------------------------------------
/bin/com/review03/ScannerLoop.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review03/ScannerLoop.class
--------------------------------------------------------------------------------
/bin/com/review03/SumEvenForLoop.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review03/SumEvenForLoop.class
--------------------------------------------------------------------------------
/bin/com/review03/SumEvenWhile.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review03/SumEvenWhile.class
--------------------------------------------------------------------------------
/bin/com/review03/Task1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review03/Task1.class
--------------------------------------------------------------------------------
/bin/com/review03/WhileDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review03/WhileDemo.class
--------------------------------------------------------------------------------
/bin/com/review04/ArrayDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review04/ArrayDemo.class
--------------------------------------------------------------------------------
/bin/com/review04/ArrayMaxMin.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review04/ArrayMaxMin.class
--------------------------------------------------------------------------------
/bin/com/review04/ScannerArray.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review04/ScannerArray.class
--------------------------------------------------------------------------------
/bin/com/review04/StringArrayScannerDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review04/StringArrayScannerDemo.class
--------------------------------------------------------------------------------
/bin/com/review04/TwoDArrayDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review04/TwoDArrayDemo.class
--------------------------------------------------------------------------------
/bin/com/review05/Q6.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review05/Q6.class
--------------------------------------------------------------------------------
/bin/com/review05/Q7.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review05/Q7.class
--------------------------------------------------------------------------------
/bin/com/review05/StringManipulation.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review05/StringManipulation.class
--------------------------------------------------------------------------------
/bin/com/review05/TwoDArrayDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review05/TwoDArrayDemo.class
--------------------------------------------------------------------------------
/bin/com/review05/TwoDArrayEnhanced.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review05/TwoDArrayEnhanced.class
--------------------------------------------------------------------------------
/bin/com/review05/TwoDArraySumEachRow.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review05/TwoDArraySumEachRow.class
--------------------------------------------------------------------------------
/bin/com/review05/TwoDArraySumMinMax.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review05/TwoDArraySumMinMax.class
--------------------------------------------------------------------------------
/bin/com/review06/ArrayManipulation.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review06/ArrayManipulation.class
--------------------------------------------------------------------------------
/bin/com/review06/Baby.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review06/Baby.class
--------------------------------------------------------------------------------
/bin/com/review06/FamilyDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review06/FamilyDemo.class
--------------------------------------------------------------------------------
/bin/com/review06/JamesMember.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review06/JamesMember.class
--------------------------------------------------------------------------------
/bin/com/review06/MathOperation.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review06/MathOperation.class
--------------------------------------------------------------------------------
/bin/com/review06/School.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review06/School.class
--------------------------------------------------------------------------------
/bin/com/review06/World.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review06/World.class
--------------------------------------------------------------------------------
/bin/com/review07/Addition.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review07/Addition.class
--------------------------------------------------------------------------------
/bin/com/review07/Dermatologist.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review07/Dermatologist.class
--------------------------------------------------------------------------------
/bin/com/review07/Doctor.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review07/Doctor.class
--------------------------------------------------------------------------------
/bin/com/review07/HospitalApplication.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review07/HospitalApplication.class
--------------------------------------------------------------------------------
/bin/com/review08/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review08/.DS_Store
--------------------------------------------------------------------------------
/bin/com/review08/Abstraction/Belarusian.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review08/Abstraction/Belarusian.class
--------------------------------------------------------------------------------
/bin/com/review08/Abstraction/Human.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review08/Abstraction/Human.class
--------------------------------------------------------------------------------
/bin/com/review08/Abstraction/Turkish.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review08/Abstraction/Turkish.class
--------------------------------------------------------------------------------
/bin/com/review08/Abstraction/World.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review08/Abstraction/World.class
--------------------------------------------------------------------------------
/bin/com/review08/Abstraction2/Apple.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review08/Abstraction2/Apple.class
--------------------------------------------------------------------------------
/bin/com/review08/Abstraction2/Crackable.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review08/Abstraction2/Crackable.class
--------------------------------------------------------------------------------
/bin/com/review08/Abstraction2/Fruit.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review08/Abstraction2/Fruit.class
--------------------------------------------------------------------------------
/bin/com/review08/Abstraction2/FruitDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review08/Abstraction2/FruitDemo.class
--------------------------------------------------------------------------------
/bin/com/review08/Abstraction2/Orange.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review08/Abstraction2/Orange.class
--------------------------------------------------------------------------------
/bin/com/review08/Abstraction2/Peelable.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review08/Abstraction2/Peelable.class
--------------------------------------------------------------------------------
/bin/com/review08/Abstraction2/Walnut.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review08/Abstraction2/Walnut.class
--------------------------------------------------------------------------------
/bin/com/review08/Abstraction2/Washable.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review08/Abstraction2/Washable.class
--------------------------------------------------------------------------------
/bin/com/review08/Polymorphism/Belarusian.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review08/Polymorphism/Belarusian.class
--------------------------------------------------------------------------------
/bin/com/review08/Polymorphism/Human.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review08/Polymorphism/Human.class
--------------------------------------------------------------------------------
/bin/com/review08/Polymorphism/Turkish.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review08/Polymorphism/Turkish.class
--------------------------------------------------------------------------------
/bin/com/review08/Polymorphism/World.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review08/Polymorphism/World.class
--------------------------------------------------------------------------------
/bin/com/review09/CollectionIntro.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review09/CollectionIntro.class
--------------------------------------------------------------------------------
/bin/com/review09/Phone.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review09/Phone.class
--------------------------------------------------------------------------------
/bin/com/review09/PhoneDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review09/PhoneDemo.class
--------------------------------------------------------------------------------
/bin/com/review09/WrapperDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review09/WrapperDemo.class
--------------------------------------------------------------------------------
/bin/com/review10/MapIntro.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review10/MapIntro.class
--------------------------------------------------------------------------------
/bin/com/review10/SetIntro.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review10/SetIntro.class
--------------------------------------------------------------------------------
/bin/com/review10/WorldMap.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review10/WorldMap.class
--------------------------------------------------------------------------------
/bin/com/review11/ExcelDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review11/ExcelDemo.class
--------------------------------------------------------------------------------
/bin/com/review11/ExcelMap.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review11/ExcelMap.class
--------------------------------------------------------------------------------
/bin/com/review11/PropertiesDemo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/bin/com/review11/PropertiesDemo.class
--------------------------------------------------------------------------------
/extra/Excel.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/extra/Excel.xlsx
--------------------------------------------------------------------------------
/extra/demo.properties:
--------------------------------------------------------------------------------
1 | FirstName=John
2 | LastName:Smith
3 | Age 30
4 |
5 | #Wrong format
6 | #Number->123
7 | School|Syntax
8 |
9 | #Reassign
10 | #FirstName=Hichem
--------------------------------------------------------------------------------
/src/com/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/src/com/.DS_Store
--------------------------------------------------------------------------------
/src/com/review01/IfElseDemo.java:
--------------------------------------------------------------------------------
1 | package com.review01;
2 |
3 | public class IfElseDemo {
4 |
5 | public static void main(String[] args) {
6 |
7 | boolean tired = false;
8 | //Be careful with curly brackets, if you open, you have to close
9 | // if (tired)
10 | // System.out.println("Ali is tired");
11 | // System.out.println("Ali goes to bed");
12 | // else
13 | // System.out.println("Ali is strong");
14 |
15 | if (tired) {
16 | System.out.println("Go to sleep!");
17 | System.out.println("Don't forget to wake up!");
18 | } else {
19 | System.out.println("Study more!");
20 | System.out.println("Continue studying!");
21 | }
22 |
23 | System.out.println("-------------------");
24 | System.out.println("Let's print the bigger number");
25 | int number1 = 14;
26 | int number2 = 10;
27 |
28 | if (number1 > number2) {
29 | System.out.println("number1 is bigger, the value is " + number1);
30 | } else if (number2 > number1) {
31 | System.out.println("number2 is bigger, the value is " + number2);
32 | } else {
33 | System.out.println("number1 and number2 are equal, the value is " + number1);
34 | }
35 |
36 | System.out.println("Let's do it Bayramgul's way");
37 |
38 | if (number1 > number2) {
39 | System.out.println("number1 is bigger, the value is " + number1);
40 | }
41 | if (number2 > number1) {
42 | System.out.println("number2 is bigger, the value is " + number2);
43 | } else {
44 | System.out.println("number1 and number2 are equal, the value is " + number1);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/com/review01/MathTask.java:
--------------------------------------------------------------------------------
1 | package com.review01;
2 |
3 | public class MathTask {
4 |
5 | public static void main(String[] args) {
6 |
7 | int number1 = 10;
8 | int number2 = 2;
9 |
10 | int sum = number1 + number2;
11 | int subtraction = number1 - number2;
12 | int multiplication = number1 * number2;
13 | int division = number1 / number2;
14 |
15 | System.out.println("number1 is " + number1);
16 | System.out.println("number2 is " + number2);
17 | System.out.println("The sum is not " + number1 + number2);
18 | System.out.println("The sum is " + (number1 + number2));
19 |
20 | System.out.println();
21 | System.out.println("The sum is " + sum);
22 | System.out.println("The subtraction is " + subtraction);
23 | System.out.println("The multiplication is " + multiplication);
24 | System.out.println("The division is " + division);
25 |
26 | System.out.println("------------------");
27 | int result = 29 / 10; // 2.9
28 | System.out.println("The result of division is " + result);
29 |
30 | int mod = 29 % 10;
31 | System.out.println("The remainder of division is " + mod);
32 |
33 | double doubleResult = 29 / 10;
34 | System.out.println("The doubleResult of division is " + doubleResult);
35 |
36 | double doubleResult2 = 29.0 / 10.0;
37 | System.out.println("The doubleResult2 of division is " + doubleResult2);
38 |
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/com/review01/PrintDemo.java:
--------------------------------------------------------------------------------
1 | package com.review01;
2 |
3 | public class PrintDemo {
4 |
5 | public static void main(String[] args) {
6 |
7 | // sout
8 | System.out.println("Hello World");
9 |
10 | // syso
11 | System.out.print("Bye");
12 |
13 | System.out.println("I am back.");
14 |
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/com/review01/ScannerDemo.java:
--------------------------------------------------------------------------------
1 | package com.review01;
2 |
3 | import java.util.Scanner;
4 |
5 | public class ScannerDemo {
6 |
7 | public static void main(String[] args) {
8 | Scanner input = new Scanner(System.in);
9 | String firstLine = input.nextLine();
10 | System.out.println("firstLine was: " + firstLine);
11 |
12 | String firstWord = input.next();
13 | System.out.println("firstWord was: " + firstWord);
14 |
15 | String secondWord = input.next();
16 | System.out.println("secondWord was: " + secondWord);
17 |
18 | String thirdWord = input.next();
19 | System.out.println("thirdWord was: " + thirdWord);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/com/review01/ScannerTask.java:
--------------------------------------------------------------------------------
1 | package com.review01;
2 |
3 | import java.util.Scanner;
4 |
5 | public class ScannerTask {
6 | public static void main(String[] args) {
7 | Scanner scan = new Scanner(System.in);
8 |
9 | System.out.println("Please enter your age:");
10 | int age = scan.nextInt();
11 | System.out.println("The age is " + age);
12 |
13 | if (age <= 10) {
14 | System.out.println("You're too young my brother!");
15 | } else if (age <= 20) {
16 | System.out.println("You're growing body!");
17 | } else if (age <= 50) {
18 | System.out.println("You're the man!");
19 | } else {
20 | System.out.println("Man, you're dying!");
21 | }
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/com/review01/TypeConversion.java:
--------------------------------------------------------------------------------
1 | package com.review01;
2 |
3 | public class TypeConversion {
4 | public static void main(String[] args) {
5 | // You don't need to memorize it :)
6 |
7 | int intNumber = 25;
8 | double doubleNumber = intNumber;
9 | System.out.println("The doubleNumber is " + doubleNumber);
10 |
11 | // 19 is between -128 and 127
12 | int numberInt = 19;
13 | byte numberByte = (byte) numberInt;
14 | System.out.println("The byte value is " + numberByte);
15 |
16 | // 260 is bigger than 256
17 | numberInt = 260;
18 | numberByte = (byte) numberInt;
19 | System.out.println("The byte value is " + numberByte);
20 |
21 | numberByte = 80;
22 | numberInt = numberByte;
23 | System.out.println("The int value is " + numberInt);
24 |
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/com/review01/VariableDemo.java:
--------------------------------------------------------------------------------
1 | package com.review01;
2 |
3 | public class VariableDemo {
4 |
5 | public static void main(String[] args) {
6 | // Declare the variable
7 | String firstName;
8 | // Assign a value
9 | firstName = "John";
10 |
11 | // Declare the variable & Assign a value
12 | String lastName = "Smith";
13 |
14 | int age = 29;
15 |
16 | System.out.println(firstName + " " + lastName + " is " + age + " years old");
17 |
18 | // re-assign a new value to the variables
19 | lastName = "Brown";
20 | age = 32;
21 |
22 | System.out.println("After getting married :)");
23 | System.out.println(firstName + " " + lastName + " is " + age + " years old");
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/com/review02/AndOperatorRichBoy.java:
--------------------------------------------------------------------------------
1 | package com.review02;
2 |
3 | import java.util.Scanner;
4 |
5 | public class AndOperatorRichBoy {
6 | public static void main(String[] args) {
7 | Scanner input = new Scanner(System.in);
8 |
9 | System.out.println("Are you a boy or a girl?");
10 | String boyGirl = input.next();
11 |
12 | System.out.println("Are you rich true/false?");
13 | boolean rich = input.nextBoolean();
14 |
15 | System.out.println("You are a " + boyGirl + " and you are rich: " + rich);
16 |
17 | if (boyGirl.equals("boy") && rich) {
18 | // only if rich boy
19 | System.out.println("Buy a ferrari.");
20 | } else if (boyGirl.equals("boy") && !rich) {
21 | // only poor boy
22 | System.out.println("Play sports");
23 | } else if (boyGirl.equals("girl") && rich) {
24 | // only rich girl
25 | System.out.println("Buy Louis Vuitton");
26 | } else if (boyGirl.equals("girl") && !rich) {
27 | // only poor girl
28 | System.out.println("Read a book");
29 | } else {
30 | // neither boy or girl
31 | System.out.println("You entered a wrong choice.");
32 | }
33 |
34 | // if (!boyGirl.equals("boy")) {
35 | // // ! means the opposite of the result
36 | // }
37 | //
38 | // if (rich) {
39 | // //only if rich is true
40 | // }
41 | //
42 | // if (!rich) {
43 | // //only if rich is false
44 | // }
45 |
46 | // if (boyGirl.equals("boy") && !rich) {
47 | // // only if is a boy and not rich
48 | // System.out.println("only if is a boy and not rich");
49 | // }
50 | //
51 | // if (!boyGirl.equals("boy") && rich) {
52 | // // only if it is not a boy and it is rich
53 | // System.out.println("only if it is not a boy and it is rich");
54 | // }
55 | //
56 | // if (!(boyGirl.equals("boy") && rich)) {
57 | // // only if it is not (rich boy)
58 | // System.out.println("only if it is not (rich boy)");
59 | // }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/com/review02/CalculatorHW.java:
--------------------------------------------------------------------------------
1 | package com.review02;
2 |
3 | import java.util.Scanner;
4 |
5 | public class CalculatorHW {
6 |
7 | public static void main(String[] args) {
8 | // String name1 = new String("John");
9 | // String name2 = new String("John");
10 | // System.out.println(name1.equals(name2));
11 | // System.out.println(name1 == name2);
12 |
13 | Scanner scan = new Scanner(System.in);
14 | System.out.print("Enter in First Number: ");
15 | int num1 = scan.nextInt();
16 |
17 | System.out.print("Enter in Operator : ");
18 | String operator = scan.next();
19 |
20 | System.out.print("Enter in Second Number: ");
21 | int num2 = scan.nextInt();
22 |
23 | if (operator.equals("+")) {
24 | System.out.println(num1 + num2);
25 | } else if (operator.equals("-")) {
26 | System.out.println(num1 - num2);
27 | } else if (operator.equals("/")) {
28 | System.out.println(num1 / num2);
29 | } else if (operator.equals("*")) {
30 | System.out.println(num1 * num2);
31 | } else {
32 | System.out.println("Invalid Operator or number entered");
33 | }
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/com/review02/IfElseIfMonth.java:
--------------------------------------------------------------------------------
1 | package com.review02;
2 |
3 | import java.util.Scanner;
4 |
5 | public class IfElseIfMonth {
6 |
7 | public static void main(String[] args) {
8 | Scanner scan = new Scanner(System.in);
9 |
10 | System.out.println("Enter a number for the month:");
11 | int month = scan.nextInt();
12 |
13 | System.out.println("The month you entered is " + month);
14 |
15 | String monthString;
16 | if (month == 1) {
17 | monthString = "January";
18 | } else if (month == 2) {
19 | monthString = "February";
20 | } else if (month == 3) {
21 | monthString = "March";
22 | } else if (month == 4) {
23 | monthString = "April";
24 | } else if (month == 5) {
25 | monthString = "May";
26 | } else if (month == 6) {
27 | monthString = "June";
28 | } else if (month == 7) {
29 | monthString = "July";
30 | } else if (month == 8) {
31 | monthString = "August";
32 | } else if (month == 9) {
33 | monthString = "September";
34 | } else if (month == 10) {
35 | monthString = "October";
36 | } else if (month == 11) {
37 | monthString = "November";
38 | } else if (month == 12) {
39 | monthString = "December";
40 | } else {
41 | monthString = "Invalid";
42 | }
43 |
44 | System.out.println("The month is " + monthString);
45 |
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/com/review02/LoopsIntro.java:
--------------------------------------------------------------------------------
1 | package com.review02;
2 |
3 | public class LoopsIntro {
4 |
5 | public static void main(String[] args) {
6 | // System.out.println("*****");
7 | // System.out.println("*****");
8 | // System.out.println("*****");
9 | // System.out.println("*****");
10 | // System.out.println("*****");
11 | // System.out.println("*****");
12 | // System.out.println("*****");
13 | // System.out.println("*****");
14 | // System.out.println("*****");
15 | // System.out.println("*****");
16 | // System.out.println("*****");
17 |
18 | // for (int i = 1; i <= 10; i++) {
19 | // System.out.println("*****");
20 | // }
21 |
22 | int age = 1;
23 | while (age <= 10) {
24 | System.out.println("My age is " + age);
25 | System.out.println("I am still young");
26 | age++;
27 | }
28 |
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/com/review02/NestedIfBuyCar.java:
--------------------------------------------------------------------------------
1 | package com.review02;
2 |
3 | import java.util.Scanner;
4 |
5 | public class NestedIfBuyCar {
6 |
7 | public static void main(String[] args) {
8 |
9 | // Write a program with one int value for salary and four String values for
10 | // different cars
11 | // If you make over 50000 a year, you may buy a brand new car otherwise you
12 | // should buy a used car. For those you can afford a new car there are different
13 | // price ranges
14 | // I want anything under 70k to be Audi A5
15 | // I want anything under 80k to be Mercedes-Benz
16 | // I want anything under 90k to be Jaguar
17 | // I want anything under 100k to be Tesla
18 | // And if you make less than 60k output to read "Save up money and wait until
19 | // next year"
20 |
21 | Scanner scan;
22 | int salary;
23 |
24 | System.out.println("Please enter your salary");
25 |
26 | scan = new Scanner(System.in);
27 | salary = scan.nextInt();
28 |
29 | String car1, car2, car3, car4;
30 |
31 | car1 = "Audi A5";
32 | car2 = "Mercedes-Benz";
33 | car3 = "Jaguar";
34 | car4 = "Tesla";
35 |
36 | if (salary > 50000) {
37 | System.out.println("You may buy a brand new car");
38 | if (salary >= 50000 && salary < 60000) {
39 | System.out.println("Save up money until next year");
40 | } else if (salary >= 60000 && salary < 70000) {
41 | System.out.println("With this salary you afford " + car1);
42 | } else if (salary >= 70000 && salary < 80000) {
43 | System.out.println("With this salary you afford " + car2);
44 | } else if (salary >= 80000 && salary < 90000) {
45 | System.out.println("With this salary you afford " + car3);
46 | } else if (salary >= 90000 && salary < 100000) {
47 | System.out.println("With this salary you afford " + car4);
48 | }
49 | } else {
50 | System.out.println("Sorry unfortunately you might want to buy a use car instead");
51 | }
52 |
53 | // 2nd way
54 | // if (salary > 50000) {
55 | // if (salary >= 60000) {
56 | // System.out.println("With this salary you afford " + car1);
57 | // } else if (salary >= 70000) {
58 | // System.out.println("With this salary you afford " + car2);
59 | // } else if (salary >= 80000) {
60 | // System.out.println("With this salary you afford " + car3);
61 | // } else if (salary >= 90000) {
62 | // System.out.println("With this salary you afford " + car4);
63 | // } else {
64 | // System.out.println("Save up money and wait until next year");
65 | // }
66 | // } else {
67 | // System.out.println("Sorry unfortunately you might want to buy a use car instead");
68 | // }
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/com/review02/NestedIfCardBalance.java:
--------------------------------------------------------------------------------
1 | package com.review02;
2 |
3 | import java.util.Scanner;
4 |
5 | public class NestedIfCardBalance {
6 |
7 | public static void main(String[] args) {
8 | /*
9 | * Create a Java program that will ask if user has a credit card or not. If you
10 | * user does not have a credit card then offer them. If they do have one ask
11 | *
12 | * what is balance on the card? If balance of the card is larger than 1000, tell
13 | * them to pay off otherwise you can tell them that they can spend more
14 | *
15 | */
16 |
17 | Scanner input = new Scanner(System.in);
18 | System.out.println("Do you have a credit card? true or false");
19 | boolean cc = input.nextBoolean();
20 | if (cc == true) {
21 | System.out.println("What is the balance on your card?");
22 | int balance = input.nextInt();
23 | if (balance > 1000) {
24 | System.out.println("Please pay off your balance");
25 | } else {
26 | System.out.println("You can spend more money");
27 | }
28 |
29 | } else {
30 | System.out.println("Would you like to apply for credit card");
31 | }
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/com/review02/NestedIfRichBoy.java:
--------------------------------------------------------------------------------
1 | package com.review02;
2 |
3 | import java.util.Scanner;
4 |
5 | public class NestedIfRichBoy {
6 |
7 | public static void main(String[] args) {
8 | Scanner input = new Scanner(System.in);
9 |
10 | System.out.println("Are you a boy or a girl?");
11 | String boyGirl = input.next();
12 |
13 | System.out.println("Are you rich true/false?");
14 | boolean rich = input.nextBoolean();
15 |
16 | System.out.println("You are a " + boyGirl + " and you are rich: " + rich);
17 |
18 | if (boyGirl.equals("boy")) {
19 | // boy
20 | System.out.println("Yaaaaay");
21 | if (rich) {
22 | // rich boy
23 | System.out.println("Buy a ferrari.");
24 | } else {
25 | // poor boy
26 | System.out.println("Play sports");
27 | }
28 |
29 | // Extra check
30 | // System.out.println("How old are you?");
31 | // int age = input.nextInt();
32 | // if (age > 20) {
33 | // System.out.println("you should marry");
34 | // } else {
35 | // System.out.println("you should study");
36 | // }
37 | } else if (boyGirl.equals("girl")) {
38 | // girl
39 | System.out.println("Yay");
40 | if (rich) {
41 | // rich girl
42 | System.out.println("Buy Louis Vuitton");
43 | } else {
44 | // poor girl
45 | System.out.println("Read a book");
46 | }
47 | } else {
48 | // neither boy or girl
49 | System.out.println("You entered a wrong choice.");
50 | }
51 |
52 | System.out.println("We are done.");
53 |
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/com/review02/NestedIfWeather.java:
--------------------------------------------------------------------------------
1 | package com.review02;
2 |
3 | import java.util.Scanner;
4 |
5 | public class NestedIfWeather {
6 |
7 | public static void main(String[] args) {
8 |
9 | // Write a program that prints out if it is good weather to go for a bike ride.
10 | // The weather is good if the temperature is between 60 degrees and 100 degrees
11 | // inclusive unless it is raining. If temperature is less than 60 program should
12 | // say
13 | // it is too cold, if the temperature is more than 100, program should say it is
14 | // too hot.
15 |
16 | /*
17 | * If the temperature is between 40 degrees and 80 degrees inclusive & no
18 | * rain--> we will go for hiking otherwise--> we will not go hiking If
19 | * temperature is between 25 and 40 inclusive & snowing -->going snowboarding
20 | * otherwise we are not going snowboarding it if temperature is more than 80 &
21 | * sunny--> go to the beach otherwise --> not go to the beach
22 | */
23 |
24 | Scanner scan;
25 | boolean snow, rain, sunny;
26 | int temp;
27 | String activity;
28 |
29 | scan = new Scanner(System.in);
30 |
31 | System.out.println("Please enter a temperature");
32 |
33 | temp = scan.nextInt();
34 |
35 | if (temp >= 40 && temp < 80) {
36 | System.out.println("Is it raining?");
37 | rain = scan.nextBoolean();
38 |
39 | if (rain) {
40 | activity = "Watch a movie";
41 | } else {
42 | activity = "Go hiking";
43 | }
44 | } else if (temp >= 25 && temp < 40) {
45 | System.out.println("Is it snowing?");
46 | snow = scan.nextBoolean();
47 | if (snow) {
48 | activity = "Snowboarding";
49 | } else {
50 | activity = "Let’s code";
51 | }
52 | } else if (temp >= 80) {
53 | System.out.println("Is it sunny");
54 | sunny = scan.nextBoolean();
55 | if (sunny) {
56 | activity = "Go to the beach";
57 | } else {
58 | activity = "Do more coding";
59 | }
60 | } else {
61 | System.out.println("Please enter different temperature");
62 | activity = "Unknown";
63 | }
64 |
65 | System.out.println("My activity for today is " + activity);
66 | }
67 |
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/com/review02/Operators.java:
--------------------------------------------------------------------------------
1 | package com.review02;
2 |
3 | import java.util.Scanner;
4 |
5 | public class Operators {
6 |
7 | public static void main(String[] args) {
8 | /*
9 | * if number is between 1-10 -->this number is small
10 | *
11 | * if number is between 10-100 --> this number is medium
12 | *
13 | * if number is between 100-1000 --> this number is large
14 | *
15 | * any other number --> is out of the range
16 | */
17 |
18 | int num = 200;
19 | // true AND false --> false
20 | if (num > 1 && num < 10) {
21 | System.out.println("this number is small");
22 | // true AND false --> false
23 | } else if (num >= 10 && num < 100) {
24 | System.out.println("this number is medium");
25 | // true AND true --> true
26 | } else if (num >= 100 && num < 1000) {
27 | System.out.println("this number is large");
28 | } else {
29 | System.out.println("Number is out of our the range");
30 | }
31 |
32 | // --------------------------------------------------------------------------------------------------------------------
33 | // --------------------------------------------------------------------------------------------------------------------
34 |
35 | /*
36 | * ask user to enter age
37 | *
38 | * if age is from 1 to 3 --> you are a baby
39 | *
40 | * if age from 3-5 --> you are a toddler
41 | *
42 | * if age from 5-12 --> you are a kid
43 | *
44 | * if age from 12-19 --> teenager
45 | *
46 | * if age >20 --> you are an adult
47 | */
48 | int age;
49 | Scanner scan;
50 | scan = new Scanner(System.in);
51 | System.out.println("Please enter your age");
52 | age = scan.nextInt();
53 | String human;
54 | if (age >= 1 && age <= 3) {
55 | // System.out.println("You are a baby");
56 | human = "baby";
57 | } else if (age > 3 && age <= 5) {
58 | // System.out.println("You are a toddler");
59 | human = "toddler";
60 | } else if (age > 5 && age <= 12) {
61 | // System.out.println("You are a kid");
62 | human = "kid";
63 | } else if (age > 12 && age <= 19) {
64 | // System.out.println("You are a teenager");
65 | human = "teenager";
66 | } else if (age > 19) {
67 | // System.out.println("You are a adult");
68 | human = "adult";
69 | } else {
70 | // System.out.println("Invalid age entered");
71 | human = "unknown";
72 | }
73 | System.out.println("You are " + human);
74 |
75 | // --------------------------------------------------------------------------------------------------------------------
76 | // --------------------------------------------------------------------------------------------------------------------
77 |
78 | // Write a program to find if a number is even or odd
79 | // Print out "My number must be even" or "My number must be odd"
80 | // Must use if else
81 |
82 | int myNumber = 11;
83 |
84 | if (myNumber % 2 == 0) {
85 | System.out.println("My number is even ");
86 | } else {
87 | System.out.println("My number is odd");
88 | }
89 |
90 | // --------------------------------------------------------------------------------------------------------------------
91 | // --------------------------------------------------------------------------------------------------------------------
92 |
93 | // Write a program to find if the largest Number of three numbers
94 | // Print out System.out.println("Largest number is " + largestNumber);
95 | // Must use if then a else if and lastly else
96 |
97 | int a, b, c;
98 | a = 2;
99 | b = 3;
100 | c = 5;
101 |
102 | if (a > b && a > c) {
103 | System.out.println("Largest number is " + a);
104 | } else if (b > c && b > a) {
105 | System.out.println("Largest number is " + b);
106 | } else {
107 | System.out.println("Largest number is " + c);
108 | }
109 |
110 | // 2nd way
111 | double n1 = -1.0, n2 = 4.5, n3 = -5.3, largestNumber;
112 | if (n1 >= n2) {
113 | if (n1 >= n3) {
114 | largestNumber = n1;
115 | } else {
116 | largestNumber = n3;
117 | }
118 | } else {
119 | if (n2 >= n3) {
120 | largestNumber = n2;
121 | } else {
122 | largestNumber = n3;
123 | }
124 | }
125 | System.out.println("Largest number is " + largestNumber);
126 |
127 | // --------------------------------------------------------------------------------------------------------------------
128 | // --------------------------------------------------------------------------------------------------------------------
129 |
130 | // Write a program to find if a number is positive or neutral or negative
131 | // Print out "My number is even" or "My number is odd"
132 | // Must use if then else if and lastly else
133 |
134 | int myNum = -3;
135 | if (myNum >= 0) {
136 | System.out.println("My number is a positive number ");
137 | } else if (myNum == 0) {
138 | System.out.println("My number is a neutral number ");
139 | } else {
140 | System.out.println("My number is a negative number");
141 | }
142 |
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/src/com/review02/SingleGuy.java:
--------------------------------------------------------------------------------
1 | package com.review02;
2 |
3 | import java.util.Scanner;
4 |
5 | public class SingleGuy {
6 | // He want to marry if she is beautiful or rich
7 | public static void main(String[] args) {
8 | Scanner input = new Scanner(System.in);
9 |
10 | System.out.println("Hey girl!");
11 | System.out.println("Are you beautiful true/false?");
12 | boolean beautiful = input.nextBoolean();
13 |
14 | System.out.println("Are you rich true/false?");
15 | boolean rich = input.nextBoolean();
16 |
17 | if (beautiful || rich) {
18 | System.out.println("The student will marry you!");
19 | } else {
20 | // ugly poor lady
21 | System.out.println("Are you a good person true/false?");
22 | boolean good = input.nextBoolean();
23 | if (good) {
24 | System.out.println("The student will give you a chance!");
25 | } else {
26 | System.out.println("Sorry, you are in a bad situation!");
27 | }
28 | }
29 |
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/com/review02/SwitchCapitalCity.java:
--------------------------------------------------------------------------------
1 | package com.review02;
2 |
3 | public class SwitchCapitalCity {
4 |
5 | public static void main(String[] args) {
6 | String country = "Pakistan";
7 | String capitalCity = "";
8 |
9 | switch (country) {
10 | case "US":
11 | capitalCity = "Washington DC";
12 | break;
13 | case "Russia":
14 | capitalCity = "Moscow";
15 | break;
16 | case "China":
17 | capitalCity = "Beijing";
18 | break;
19 | case "Albania":
20 | capitalCity = "Tirana";
21 | break;
22 | case "Pakistan":
23 | capitalCity = "Islamabad";
24 | break;
25 | case "Turkey":
26 | capitalCity = "Ankara";
27 | break;
28 | default:
29 | capitalCity = "not in my list";
30 | break;
31 | }
32 | System.out.println("The capital city of " + country + " is " + capitalCity);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/com/review02/SwitchLevel.java:
--------------------------------------------------------------------------------
1 | package com.review02;
2 |
3 | public class SwitchLevel {
4 |
5 | public static void main(String[] args) {
6 |
7 | // Write a program to find out the user level of experience
8 | // Must use a switch statement with a String variable named levelString and a
9 | // int variable named level
10 | // Beginner level should be 1
11 | // Intermediate level should be 2
12 | // Expert level should be 3
13 |
14 | // Declaring String variable
15 | String levelString = "Expert";
16 | int level = 0;
17 | // Using String in Switch expression
18 | switch (levelString) {
19 | // Using String Literal in Switch case
20 | case "Beginner":
21 | level = 1;
22 | break;
23 | case "Intermediate":
24 | level = 2;
25 | break;
26 | case "Expert":
27 | level = 3;
28 | break;
29 | default:
30 | level = 0;
31 | break;
32 | }
33 | System.out.println("Your Level is: " + level);
34 | }
35 | }
--------------------------------------------------------------------------------
/src/com/review02/SwitchMonth.java:
--------------------------------------------------------------------------------
1 | package com.review02;
2 |
3 | import java.util.Scanner;
4 |
5 | public class SwitchMonth {
6 | // Write a program that uses a switch statement to display the month we're in.
7 | // Down there is weekday program.
8 |
9 | public static void main(String[] args) {
10 | Scanner scan = new Scanner(System.in);
11 |
12 | System.out.println("Enter a number for the month:");
13 | int month = scan.nextInt();
14 |
15 | // System.out.println("The month you entered is " + month);
16 |
17 | String monthString = "";
18 |
19 | switch (month) {
20 | case 1:
21 | monthString = "January";
22 | break;
23 | case 2:
24 | monthString = "February";
25 | break;
26 | case 3:
27 | monthString = "March";
28 | break;
29 | case 4:
30 | monthString = "April";
31 | // break; //If we comment the break, the next lines will be executed
32 | case 5:
33 | monthString = "May";
34 | break;
35 | case 6:
36 | monthString = "June";
37 | break;
38 | case 7:
39 | monthString = "July";
40 | break;
41 | case 8:
42 | monthString = "August";
43 | break;
44 | case 9:
45 | monthString = "September";
46 | break;
47 | case 10:
48 | monthString = "October";
49 | break;
50 | case 11:
51 | monthString = "November";
52 | break;
53 | case 12:
54 | monthString = "December";
55 | break;
56 | default:
57 | monthString = "Invalid";
58 | break;
59 | }
60 |
61 | System.out.println("The month is " + monthString);
62 |
63 | /*
64 | * 7 weekdays; if day==1--> Monday; if day==2 --> Tuesday;
65 | */
66 | // int day = 6;
67 | // String weekDay;
68 | // if (day == 1) {
69 | // weekDay = "Monday";
70 | // } else if (day == 2) {
71 | // weekDay = "Tuesday";
72 | // } else if (day == 3) {
73 | // weekDay = "Wednesday";
74 | // } else if (day == 4) {
75 | // weekDay = "Thursday";
76 | // } else if (day == 5) {
77 | // weekDay = "Friday";
78 | // } else if (day == 6) {
79 | // weekDay = "Saturday";
80 | // } else if (day == 7) {
81 | // weekDay = "Sunday";
82 | // } else {
83 | // weekDay = "Invalid";
84 | // }
85 |
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/com/review03/ContinueDemo.java:
--------------------------------------------------------------------------------
1 | package com.review03;
2 |
3 | public class ContinueDemo {
4 | // I want to celebrate my son's 20 birthdays
5 | // but not 13th birthday
6 | // Let's use for loop
7 | public static void main(String[] args) {
8 | // int age = 0;
9 | // while (age < 10) {
10 | // age++;
11 | // System.out.println("Happy birthday! You are " + age + " years old.");
12 | // }
13 | // System.out.println("Now you are grown! You don't need a birthday celebration.");
14 |
15 | for (int age = 1; age <= 20; age++) {
16 | // 1st way without continue
17 | // if (age != 13) {
18 | // System.out.println("Happy birthday! You are " + age + " years old.");
19 | // }
20 |
21 | // 2nd way without continue
22 | // if (age == 13) {
23 | //
24 | // } else {
25 | // System.out.println("Happy birthday! You are " + age + " years old.");
26 | // }
27 |
28 | // 3rd way with continue
29 | if (age == 13) {
30 | continue;
31 | }
32 | System.out.println("Happy birthday! You are " + age + " years old.");
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/com/review03/DoWhileDemo.java:
--------------------------------------------------------------------------------
1 | package com.review03;
2 |
3 | public class DoWhileDemo {
4 |
5 | public static void main(String[] args) {
6 |
7 | // Similarity between while && do-while
8 | int age = 0; // just born
9 |
10 | while (age < 10) {
11 | age++;
12 | System.out.println("Happy birthday! You are " + age + " years old.");
13 | }
14 | System.out.println("Now you are grown! You don't need a birthday celebration.");
15 |
16 | int age2 = 0; // just born my second son
17 | do {
18 | age2++;
19 | System.out.println("Happy birthday! You are " + age2 + " years old.");
20 | } while (age2 < 10);
21 | System.out.println("Now you are grown! You don't need a birthday celebration.");
22 |
23 | // Difference between while && do-while
24 | String greeting = "Hi";
25 | boolean happy = false;
26 | while (happy) {
27 | System.out.println(greeting + " inside while");
28 | }
29 |
30 | do {
31 | System.out.println(greeting + " inside do-while");
32 | } while (false);
33 |
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/com/review03/ScannerLoop.java:
--------------------------------------------------------------------------------
1 | package com.review03;
2 |
3 | import java.util.Scanner;
4 |
5 | public class ScannerLoop {
6 | // Ask the user to enter many positive number and add it to the total
7 | // He should enter -1 to STOP. -1 will not be added to the total
8 |
9 | public static void main(String[] args) {
10 | Scanner input = new Scanner(System.in);
11 | int total = 0;
12 | int number = 0;
13 |
14 | // 1st way, using while
15 | // System.out.println("Enter a number. To stop enter -1");
16 | // number = input.nextInt();
17 | //
18 | // while (number != -1) {
19 | // total += number;
20 | //
21 | // System.out.println("Enter a number. To stop enter -1");
22 | // number = input.nextInt();
23 | // }
24 | // System.out.println("The total is = " + total);
25 |
26 | // 2nd way, using do-while
27 | // do {
28 | // System.out.println("Enter a number. To stop enter -1");
29 | // number = input.nextInt();
30 | // // a version, to check for -1
31 | //// if (number == -1) {
32 | //// break;
33 | //// } else {
34 | //// total += number;
35 | //// }
36 | //
37 | // // b version, to check for -1
38 | // if (number != -1) {
39 | // total += number;
40 | // }
41 | // } while (number != -1);
42 | // System.out.println("The total is = " + total);
43 |
44 | // 3rd way, using for
45 | for (; number != -1;) {
46 | System.out.println("Enter a number. To stop enter -1");
47 | number = input.nextInt();
48 | if (number != -1) {
49 | total += number;
50 | }
51 | }
52 |
53 | System.out.println("The total is = " + total);
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/com/review03/SumEvenForLoop.java:
--------------------------------------------------------------------------------
1 | package com.review03;
2 |
3 | public class SumEvenForLoop {
4 | // Add Even numbers
5 | // Also add Odd numbers
6 | // Also add All numbers
7 | // Between 1 && 50
8 | // Using for loop
9 | public static void main(String[] args) {
10 | int totalOdd = 0, totalEven = 0, grandTotal = 0;
11 |
12 | for (int count = 1; count <= 50; count++) {
13 | if (count % 2 == 0) {
14 | totalEven += count;
15 | } else {
16 | totalOdd += count;
17 | }
18 | // 2nd way to calculate grandTotal
19 | grandTotal += count;
20 | }
21 | System.out.println("totalEven is = " + totalEven);
22 | System.out.println("totalOdd is = " + totalOdd);
23 |
24 | // 1st way to calculate grandTotal
25 | // grandTotal = totalEven + totalOdd;
26 | System.out.println("grandTotal is = " + grandTotal);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/com/review03/SumEvenWhile.java:
--------------------------------------------------------------------------------
1 | package com.review03;
2 |
3 | public class SumEvenWhile {
4 | // Add Even numbers
5 | // Also add Odd numbers
6 | // Between 1 && 50
7 | // you can use while or do-while
8 | // you can use mod operator or add by 2
9 | public static void main(String[] args) {
10 | int count = 1;
11 | int totalOdd = 0, totalEven = 0;
12 |
13 | // 1st way
14 | while (count <= 50) {
15 | if (count % 2 == 0) {
16 | totalEven += count;
17 | } else {
18 | totalOdd += count;
19 | }
20 | count++;
21 | }
22 | System.out.println("totalEven is = " + totalEven);
23 | System.out.println("totalOdd is = " + totalOdd);
24 |
25 | System.out.println("Using do-while");
26 | // 2nd way. This adds only odd
27 | count = 1;
28 | totalOdd = 0;
29 | do {
30 | totalOdd += count;
31 | count += 2;
32 | } while (count <= 50);
33 | System.out.println("totalOdd is = " + totalOdd);
34 |
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/com/review03/Task1.java:
--------------------------------------------------------------------------------
1 | package com.review03;
2 |
3 | public class Task1 {
4 | // print number from 15 to 35
5 | // but don't print numbers that are divisible by both 2 and 3, at the same time
6 |
7 | public static void main(String[] args) {
8 |
9 | for (int i = 15; i <= 35; i++) {
10 |
11 | // 1st way, divisible by 6
12 | // if (i % 6 == 0) {
13 | // continue;
14 | // }
15 | // System.out.println(i);
16 |
17 | // 2nd way, using &&
18 | // if (i % 2 == 0 && i % 3 == 0) {
19 | // continue;
20 | // }
21 | // System.out.println(i);
22 |
23 | // 3rd way, using ||
24 | if (i % 2 != 0 || i % 3 != 0) {
25 | System.out.println(i);
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/com/review03/WhileDemo.java:
--------------------------------------------------------------------------------
1 | package com.review03;
2 |
3 | public class WhileDemo {
4 |
5 | public static void main(String[] args) {
6 | String greeting = "Hello";
7 | int count = 1;
8 |
9 | // boolean condition = (count <= 5);
10 |
11 | while (count <= 5) {
12 | // count = count + 1;
13 | // count += 1;
14 | count++;
15 | System.out.println(greeting);
16 | }
17 |
18 | System.out.println("===========================");
19 | // reassigning count to 1
20 | count = 1;
21 |
22 | while (true) {
23 | count++;
24 | System.out.println(greeting);
25 | if (count == 6) {
26 | break;
27 | }
28 | }
29 |
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/com/review04/ArrayDemo.java:
--------------------------------------------------------------------------------
1 | package com.review04;
2 |
3 | public class ArrayDemo {
4 |
5 | public static void main(String[] args) {
6 | // silly way
7 | int a0 = 5;
8 | int a1 = 7;
9 | int a2 = 8;
10 | int a3 = 9;
11 | int a4 = 20;
12 | // System.out.println(a0);
13 | // System.out.println(a1);
14 | // System.out.println(a2);
15 | // System.out.println(a3);
16 | // System.out.println(a4);
17 |
18 | // 1st professional way
19 | // declaring an array, all elements have the default value
20 | int[] numbers = new int[5];
21 |
22 | // assigning values for array elements
23 | numbers[3] = 9;
24 | // re-assign
25 | // numbers[3] = 10;
26 | numbers[2] = 8;
27 | numbers[1] = 7;
28 | numbers[0] = 5;
29 | numbers[4] = 20;
30 |
31 | System.out.println(numbers[0]);
32 | System.out.println(numbers[1]);
33 | System.out.println(numbers[2]);
34 | System.out.println(numbers[3]);
35 | System.out.println(numbers[4]);
36 |
37 | // printing the element with index 2, third element
38 | System.out.println("printing using index with variable");
39 | int index = 2;
40 | System.out.println(numbers[index]);
41 | index++;
42 | System.out.println(numbers[index]);
43 |
44 | int arrayLength = numbers.length;
45 | System.out.println("The length of the array is : " + arrayLength);
46 |
47 | // method a. using for loop
48 | // this method can iterate from start-point to end-point
49 | System.out.println("Reading from array using for loop");
50 | for (int j = 0; j < arrayLength; j++) {
51 | System.out.println(numbers[j]);
52 | }
53 |
54 | // method b. using for-each loop/advanced for loop/enhanced for loop
55 | // this method iterates the whole array
56 | System.out.println("Reading from array using for-each loop/advanced for loop/enhanced for loop");
57 | for (int number : numbers) {
58 | System.out.println(number);
59 | }
60 |
61 | // 2nd professional way of initializing array
62 | System.out.println("Second way uzing curly brackets");
63 | int[] numbers2 = { 4, 6, 8, 9, 15 };
64 | System.out.println("Length is " + numbers2.length);
65 |
66 | System.out.println("For Loop");
67 | for (int j = 0; j < numbers2.length; j++) {
68 | System.out.println(numbers2[j]);
69 | }
70 |
71 | System.out.println("Enhanced For Loop");
72 | for (int number : numbers2) {
73 | System.out.println(number);
74 | }
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/src/com/review04/ArrayMaxMin.java:
--------------------------------------------------------------------------------
1 | package com.review04;
2 |
3 | public class ArrayMaxMin {
4 | // Find largest and smallest number in an array
5 | public static void main(String[] args) {
6 | int[] numbers = { 34, 67, 3, 93, 56, 72, 17, 33 };
7 |
8 | int largest = numbers[0];
9 | int smallest = numbers[0];
10 | int sum = 0;
11 |
12 | for (int num : numbers) {
13 | if (num > largest) {
14 | largest = num;
15 | }
16 |
17 | if (num < smallest) {
18 | smallest = num;
19 | }
20 |
21 | sum += num;
22 | }
23 |
24 | System.out.println("The largest number is: " + largest);
25 | System.out.println("The smallest number is: " + smallest);
26 | System.out.println("The sum of all numbers is: " + sum);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/com/review04/ScannerArray.java:
--------------------------------------------------------------------------------
1 | package com.review04;
2 |
3 | import java.util.Scanner;
4 |
5 | public class ScannerArray {
6 | // Use scanner to ask for the size of the array
7 | // Then, read numbers from the scanner into the array
8 | // Then print the whole array
9 |
10 | public static void main(String[] args) {
11 | Scanner scan = new Scanner(System.in);
12 | System.out.println("How many elements do you want to store, buddy?");
13 | int size = scan.nextInt();
14 |
15 | // I am creating an array with size = whatever he/she gave us
16 | int[] nums = new int[size];
17 |
18 | // This for loop inserts numbers into array
19 | for (int i = 0; i < size; i++) {
20 | System.out.println("Give me a number to store in the array!");
21 | nums[i] = scan.nextInt();
22 | }
23 |
24 | System.out.println("Let's see what you gave me:");
25 | // This enhanced for loop reads numbers from the array
26 | for (int n : nums) {
27 | System.out.println(n);
28 | }
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/com/review04/StringArrayScannerDemo.java:
--------------------------------------------------------------------------------
1 | package com.review04;
2 |
3 | import java.util.Scanner;
4 |
5 | public class StringArrayScannerDemo {
6 |
7 | public static void main(String[] args) {
8 | Scanner input = new Scanner(System.in);
9 |
10 | System.out.println("How many animals do you have?");
11 | int length = input.nextInt();
12 |
13 | String[] animals = new String[length];
14 |
15 | for (int count = 0; count < length; count++) {
16 | System.out.println("Give me an animal.");
17 | String animal = input.nextLine();
18 | animals[count] = animal;
19 | }
20 |
21 | System.out.println("===================");
22 |
23 | for (String str : animals) {
24 | System.out.println(str);
25 | }
26 |
27 | System.out.println("===================");
28 | System.out.println("Print in reverse order");
29 | for (int i = animals.length - 1; i >= 0; i--) {
30 | String str = animals[i];
31 | System.out.println(str);
32 | }
33 |
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/com/review04/TwoDArrayDemo.java:
--------------------------------------------------------------------------------
1 | package com.review04;
2 |
3 | public class TwoDArrayDemo {
4 |
5 | public static void main(String[] args) {
6 |
7 | // 1st way of creating 2d-array
8 | int[][] numbers = new int[2][3];
9 |
10 | // enter into array. into row index 0 and column index 2
11 | numbers[0][2] = 8;
12 | numbers[0][0] = 5;
13 | numbers[1][0] = 9;
14 | numbers[0][1] = 6;
15 | numbers[1][1] = 2;
16 | numbers[1][2] = 3;
17 |
18 | // 2nd way of creating 2d-array
19 | int[][] numbers2 = { { 5, 6, 8 }, { 9, 2, 3 } };
20 |
21 | System.out.println("Let's get some values from numbers2");
22 | // first get it, then print it
23 | int value = numbers2[1][0];
24 | System.out.println(value);
25 |
26 | // get and print in one step
27 | System.out.println(numbers2[1][1]);
28 |
29 | // 1d-array is married to for loop
30 | // 2d-array is married to nested for loop
31 |
32 | // how many rows?
33 | int rows = numbers2.length;
34 | // how many columns in first row?
35 | int columns = numbers2[0].length;
36 |
37 | for (int row = 0; row < numbers2.length; row++) {
38 | System.out.println("I am in the " + row + " row");
39 | for (int col = 0; col < numbers2[row].length; col++) {
40 | System.out.print("I am in column " + col);
41 | System.out.println(" The value is " + numbers2[row][col]);
42 | }
43 | System.out.println();
44 | }
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/com/review05/Q6.java:
--------------------------------------------------------------------------------
1 | package com.review05;
2 |
3 | public class Q6 {
4 | // Write a Java Program to find whether a String is palindrome or not?
5 | public static void main(String[] args) {
6 | String str = "radar kayak radar";
7 |
8 | // 1st way
9 | char[] charArray = str.toCharArray();
10 |
11 | String reverse = "";
12 | System.out.println(reverse.isEmpty());
13 |
14 | for (int i = charArray.length - 1; i >= 0; i--) {
15 | reverse += charArray[i];
16 | }
17 | System.out.println("word is=" + str);
18 | System.out.println("reverse is=" + reverse);
19 |
20 | if(str.equals(reverse)) {
21 | System.out.println("Yes, it is a palindrome");
22 | }else {
23 | System.out.println("No, it is not a palindrome");
24 | }
25 |
26 | //HW use charAt() method to find if it is a palindrome
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/com/review05/Q7.java:
--------------------------------------------------------------------------------
1 | package com.review05;
2 |
3 | import java.util.Arrays;
4 |
5 | public class Q7 {
6 | // Write a java program to find the second largest number in the array?
7 | // Maximum and minimum number in the array?
8 | public static void main(String[] args) {
9 |
10 | int[] numbers = { 32, 61, 16, 89, 74, 25 };
11 |
12 | // 1st way
13 | Arrays.sort(numbers);
14 | System.out.println("Smallest " + numbers[0]);
15 | System.out.println("Biggest " + numbers[numbers.length - 1]);
16 | System.out.println("Second Largest " + numbers[numbers.length - 2]);
17 |
18 | // 2nd way
19 | System.out.println("---2nd way---");
20 | int[] numbers2 = { 32, 61, 16, 89, 74, 25 };
21 |
22 | int smallest = numbers2[0];
23 | int largest = numbers2[0];
24 | int largest2 = numbers2[0];
25 |
26 | for (int i = 1; i < numbers2.length; i++) {
27 | int element = numbers2[i];
28 | // check if it is bigger than the largest
29 | if (element > largest) {
30 | largest2 = largest;
31 | largest = element;
32 | } else if (element > largest2) { // check if it is bigger than second largest
33 | largest2 = element;
34 | }
35 |
36 | if (element < smallest) {
37 | smallest = element;
38 | }
39 | }
40 | System.out.println("Smallest " + smallest);
41 | System.out.println("Biggest " + largest);
42 | System.out.println("Second Largest " + largest2);
43 |
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/com/review05/StringManipulation.java:
--------------------------------------------------------------------------------
1 | package com.review05;
2 |
3 | public class StringManipulation {
4 |
5 | public static void main(String[] args) {
6 | String str = "Hello2! ";
7 |
8 | System.out.println(str.length());
9 | System.out.println(str.toUpperCase());
10 |
11 | // str has not changed
12 | System.out.println(str);
13 | System.out.println(str.toLowerCase());
14 |
15 | System.out.println(str.equals("hello2! "));
16 | System.out.println(str.equalsIgnoreCase("hello2! "));
17 |
18 | boolean starts = str.startsWith("he");
19 | System.out.println("str.startsWith(he) -> " + starts);
20 | System.out.println(str.endsWith("2! "));
21 |
22 | // Method chaining
23 | starts = str.toLowerCase().startsWith("he");
24 | System.out.println(starts);
25 |
26 | char fifthCharacter = str.charAt(4);
27 | System.out.println(fifthCharacter);
28 |
29 | String reverse = "";
30 | char[] charArray = str.toCharArray();
31 | for (int i = charArray.length - 1; i >= 0; i--) {
32 | // System.out.print(charArray[i]);
33 | reverse += charArray[i];
34 | }
35 |
36 | System.out.println("reverse is ->" + reverse);
37 |
38 | int index = str.indexOf("llo");
39 | System.out.println(index);
40 |
41 | String example = "Something inside here";
42 | int index2 = example.indexOf("e", 19);
43 | System.out.println(index2);
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/com/review05/TwoDArrayDemo.java:
--------------------------------------------------------------------------------
1 | package com.review05;
2 |
3 | public class TwoDArrayDemo {
4 |
5 | public static void main(String[] args) {
6 | // 1st way
7 | int[][] numbers = new int[3][4];
8 |
9 | // Let's print third element in second row
10 | System.out.println("third element in second row is " + numbers[1][2]);
11 |
12 | // Let us initialize values for second row = row index 1
13 | numbers[1][0] = 9;
14 | numbers[1][1] = 6;
15 | numbers[1][2] = 2;
16 | numbers[1][3] = 8;
17 |
18 | // Let's print third element in second row
19 | System.out.println("third element in second row is " + numbers[1][2]);
20 |
21 | // Let us initialize values for first row = row index 0
22 | numbers[0][0] = 7;
23 | numbers[0][1] = 1;
24 | numbers[0][2] = 6;
25 | numbers[0][3] = 12;
26 |
27 | // Let us initialize values for third row = row index 2
28 | numbers[2][0] = 3;
29 | numbers[2][1] = 0;
30 | numbers[2][2] = 8;
31 | numbers[2][3] = 5;
32 |
33 | // 2nd way
34 | int[][] numbers2 = {
35 | { 7, 1, 6, 12 },
36 | { 9, 6, 2, 8, 1, 4 },
37 | { 3, 0, 8, 5 }
38 | };
39 | // Let's print fourth element in first row
40 | System.out.println("fourth element in first row " + numbers2[0][3]);
41 |
42 | int row = numbers2.length;
43 | System.out.println("rows=" + row);
44 |
45 | int length0 = numbers2[0].length;
46 | int length1 = numbers2[1].length;
47 | int length2 = numbers2[2].length;
48 |
49 | System.out.println("row0=" + length0 + " row1=" + length1 + " row2=" + length2);
50 |
51 | // 3rd way, The coolest way :)
52 | int[][] numbers3 = new int[3][];
53 | numbers3[0] = new int[4];
54 | numbers3[1] = new int[6];
55 | numbers3[2] = new int[5];
56 |
57 | System.out.println();
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/com/review05/TwoDArrayEnhanced.java:
--------------------------------------------------------------------------------
1 | package com.review05;
2 |
3 | public class TwoDArrayEnhanced {
4 |
5 | public static void main(String[] args) {
6 | int[][] num = { { 7, 1, 6, 12 }, { 9, 6, 2, 8 }, { 3, 0, 8, 5 } };
7 |
8 | int sum = 0;
9 | // iterating rows of a 2D array
10 | for (int[] row : num) {
11 |
12 | // iterating elements of a row
13 | for (int element : row) {
14 | System.out.print(element + " ");
15 | sum += element;
16 | }
17 | System.out.println();
18 |
19 | }
20 |
21 | System.out.println("The sum is " + sum);
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/com/review05/TwoDArraySumEachRow.java:
--------------------------------------------------------------------------------
1 | package com.review05;
2 |
3 | public class TwoDArraySumEachRow {
4 | public static void main(String[] args) {
5 | int[][] num = { { 7, 1, 6, 12 }, { 9, 6, 2, 8 }, { 3, 0, 8, 5 } };
6 |
7 | int[] sum = new int[num.length];
8 |
9 | for (int row = 0; row < num.length; row++) {
10 | for (int col = 0; col < num[row].length; col++) {
11 | int element = num[row][col];
12 | sum[row] += element;
13 | }
14 | }
15 |
16 | // Let's iterate the sum array
17 | for (int element : sum) {
18 | System.out.println("Sum is " + element);
19 | }
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/com/review05/TwoDArraySumMinMax.java:
--------------------------------------------------------------------------------
1 | package com.review05;
2 |
3 | public class TwoDArraySumMinMax {
4 |
5 | public static void main(String[] args) {
6 | int[][] num = { { 7, 1, 6, 12 }, { 9, 6, 2, 8 }, { 3, 0, 8, 5 } };
7 |
8 | // Iterating a 2D Array
9 | int rows = num.length;
10 | for (int row = 0; row < rows; row++) {
11 |
12 | for (int col = 0; col < num[row].length; col++) {
13 | int element = num[row][col];
14 | System.out.print(element + " ");
15 | }
16 |
17 | System.out.println();
18 | }
19 |
20 | // Sum a all elements in a 2D Array
21 | int sum = 0;
22 | // iterating rows
23 | for (int row = 0; row < num.length; row++) {
24 | // iterating elements of a row
25 | for (int col = 0; col < num[row].length; col++) {
26 | sum += num[row][col];
27 | }
28 | }
29 | System.out.println("The sum of all number is " + sum);
30 |
31 | // finding min and max number in a 2D array
32 | int min = num[0][0];
33 | int max = num[0][0];
34 |
35 | for (int i = 0; i < num.length; i++) {
36 | for (int j = 0; j < num[i].length; j++) {
37 | int element = num[i][j];
38 | if (element < min) {
39 | min = element;
40 | }
41 |
42 | if (element > max) {
43 | max = element;
44 | }
45 | }
46 | }
47 | System.out.println("the maximum is " + max);
48 | System.out.println("the minimum is " + min);
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/com/review06/ArrayManipulation.java:
--------------------------------------------------------------------------------
1 | package com.review06;
2 |
3 | public class ArrayManipulation {
4 |
5 | public static void main(String[] args) {
6 | int[] arr = { 5, 2, 9, 6, 1, 8 };
7 |
8 | double avg = findAverage(arr);
9 | System.out.println("average is " + avg);
10 |
11 | ArrayManipulation manip = new ArrayManipulation();
12 |
13 | int largest = manip.largestNumber(arr);
14 | System.out.println("largest is " + largest);
15 |
16 | System.out.println("smallest is " + manip.smallestNumber(arr));
17 |
18 | // HW
19 | // create a method that returns sum of an array
20 | }
21 |
22 | public int largestNumber(int[] array) {
23 | int largest = array[0];
24 |
25 | for (int i = 0; i < array.length; i++) {
26 | if (array[i] > largest) {
27 | largest = array[i];
28 | }
29 | }
30 |
31 | return largest;
32 | }
33 |
34 | int smallestNumber(int[] array) {
35 | int smallest = array[0];
36 | for (int num : array) {
37 | if (num < smallest) {
38 | smallest = num;
39 | }
40 | }
41 | return smallest;
42 | }
43 |
44 | //even if it is private it can be called from inside the class.
45 | private static double findAverage(int[] array) {
46 | double sum = 0;
47 |
48 | for (int num : array) {
49 | sum += num;
50 | }
51 |
52 | return sum / array.length;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/com/review06/Baby.java:
--------------------------------------------------------------------------------
1 | package com.review06;
2 |
3 | public class Baby {
4 | String firstName;
5 | String lastName;
6 | char gender;
7 | int weight;
8 | String hairColor;
9 |
10 | public void walk() {
11 | System.out.println("Crawling...");
12 | }
13 |
14 | protected String cry() {
15 | return "Cry every minute....";
16 | }
17 |
18 | void talk(int times) {
19 | for (int i = 1; i <= times; i++) {
20 | System.out.print("Bla ");
21 | }
22 | }
23 |
24 | public void displayBabyInfo() {
25 | System.out.println("Full name of baby is " + this.firstName + " " + this.lastName);
26 | System.out.print("Gender is ");
27 | if (gender == 'M') {
28 | System.out.println("Boy");
29 | } else if (gender == 'F') {
30 | System.out.println("Girl");
31 | } else {
32 | System.out.println(" unknown");
33 | }
34 |
35 | System.out.println("Hair color is " + hairColor);
36 | }
37 |
38 | }
--------------------------------------------------------------------------------
/src/com/review06/FamilyDemo.java:
--------------------------------------------------------------------------------
1 | package com.review06;
2 |
3 | public class FamilyDemo {
4 | public static void main(String[] args) {
5 | JamesMember.lastName = "James";
6 | // JamesMember.firstName = "John";
7 |
8 | JamesMember member1 = new JamesMember();
9 | member1.firstName = "Lebron";
10 | member1.age = 34;
11 |
12 | JamesMember member2 = new JamesMember();
13 | member2.firstName = "Savannah";
14 | member2.age = 28;
15 |
16 | member1.fullName();
17 | member2.fullName();
18 |
19 | // HW for Hichem
20 | // Create another class called SmithMember
21 | // have a static int variable count
22 | // when you create a member of Smith Family
23 | // you increment the count by one
24 | // print how many members of
25 | // Smith Family they are
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/com/review06/JamesMember.java:
--------------------------------------------------------------------------------
1 | package com.review06;
2 |
3 | public class JamesMember {
4 | String firstName; // belongs to the instance
5 | static String lastName; // static belong to the class
6 | int age; // belongs to the object
7 |
8 | void fullName() {
9 | System.out.println("Full name is " + firstName + " " + lastName);
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/src/com/review06/MathOperation.java:
--------------------------------------------------------------------------------
1 | package com.review06;
2 |
3 | public class MathOperation {
4 |
5 | // can be accessed from everywhere
6 | public int add(int num1, int num2) {
7 | int addition = num1 + num2;
8 | return addition;
9 | }
10 |
11 | // can be accessed from inside package, and inheritance
12 | protected void addNoReturn(int num1, int num2) {
13 | int addition = num1 + num2;
14 | System.out.println("Printing the result " + "inside the method " + addition);
15 | }
16 |
17 | // can be accessed from inside package
18 | int multiply(int num1, int num2) {
19 | return num1 * num2;
20 | }
21 |
22 | // can be accessed only within this class
23 | private void smth() {
24 |
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/com/review06/School.java:
--------------------------------------------------------------------------------
1 | package com.review06;
2 |
3 | public class School {
4 |
5 | public static void main(String[] args) {
6 | MathOperation math = new MathOperation();
7 |
8 | int result = math.add(4, 5);
9 | System.out.println("result is " + result);
10 |
11 | math.addNoReturn(4, 5);
12 |
13 | System.out.println(math.add(5, 2));
14 |
15 | result = math.multiply(3, 4);
16 | System.out.println("multiplication result is " + result);
17 |
18 | // cannot access this method, because it is private
19 | // math.smth();
20 |
21 | // HW only for Farid :)
22 | // create divide method
23 | // create substruct method
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/com/review06/World.java:
--------------------------------------------------------------------------------
1 | package com.review06;
2 |
3 | public class World {
4 |
5 | public static void main(String[] args) {
6 | Baby baby1;
7 | baby1 = new Baby();
8 |
9 | System.out.println(baby1.cry());
10 |
11 | // assign values
12 | baby1.firstName = "John";
13 | baby1.lastName = "Smith";
14 | baby1.gender = 'M';
15 | baby1.weight = 7;
16 | baby1.hairColor = "Yellow";
17 |
18 | // reassign value
19 | baby1.weight = 8;
20 |
21 | System.out.println("baby1 firstname is " + baby1.firstName);
22 |
23 | String variable = baby1.lastName;
24 | System.out.println("baby LastName " + variable);
25 |
26 | String cryVariable = baby1.cry();
27 | System.out.println(cryVariable);
28 | baby1.walk();
29 | baby1.talk(3);
30 |
31 | System.out.println("\n--- Done with baby 1 ---");
32 |
33 | Baby baby2 = new Baby();
34 |
35 | System.out.println(baby2.cry());
36 |
37 | baby2.firstName = "Selin";
38 | baby2.lastName = "Atasoy";
39 | baby2.gender = 'F';
40 | baby2.hairColor = "Black";
41 | baby2.weight = 6;
42 |
43 |
44 | System.out.println("--------------------------");
45 | baby1.displayBabyInfo();
46 | System.out.println("--------------------------");
47 | baby2.displayBabyInfo();
48 | System.out.println("--------------------------");
49 |
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/com/review07/Addition.java:
--------------------------------------------------------------------------------
1 | package com.review07;
2 |
3 | public class Addition {
4 | // Overloading methods
5 | // They all have same name, but different parameter
6 |
7 | public static void add(int a, int b) {
8 | System.out.println("The sum is " + (a + b));
9 | }
10 |
11 | public static void add(int a, int b, int c) {
12 | System.out.println("The sum is " + (a + b + c));
13 | }
14 |
15 | public static void add(int a, double b) {
16 | System.out.println("The sum is " + (a + b));
17 | }
18 |
19 | public static void add(double a, int b) {
20 | System.out.println("The sum is " + (a + b));
21 | }
22 |
23 | public static void main(String[] args) {
24 | add(4, 5);
25 | add(3, 5, 8);
26 | add(3, 4.5);
27 | add(3.2, 6);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/com/review07/Dermatologist.java:
--------------------------------------------------------------------------------
1 | package com.review07;
2 |
3 | public class Dermatologist extends Doctor {
4 | String dermaId;
5 |
6 | // super.name is same as this.name
7 | // super.chargePatient() is same as this.chargePatient()
8 | // But after overriding, they are NOT the same
9 |
10 | public Dermatologist(String name, String licenceId, int salary, String dermaId) {
11 | super(name, licenceId, salary);
12 | this.dermaId = dermaId;
13 | }
14 |
15 | public void skinTest() {
16 | System.out.println("Let's apply some skin test.");
17 | }
18 |
19 | // Method overriding
20 | public void chargePatient() {
21 | System.out.println("Let me charge $200.");
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/com/review07/Doctor.java:
--------------------------------------------------------------------------------
1 | package com.review07;
2 |
3 | public class Doctor {
4 | static String hospitalName;
5 | String name;
6 | String licenceId;
7 | int salary;
8 |
9 | // one more variable added
10 | String address;
11 |
12 | // public Doctor() {
13 | // //super();
14 | // }
15 |
16 | public Doctor(String name, String licenceId, int salary) {
17 | // super(); // I am calling super() by default
18 | this.name = name;
19 | this.licenceId = licenceId;
20 | this.salary = salary;
21 | }
22 |
23 | public Doctor(String name, String licenceId, int salary, String address) {
24 | this(name, licenceId, salary);
25 | this.address = address;
26 | }
27 |
28 | public void checkUp(String patientName) {
29 | System.out.println("Doctor " + name + " has ordered blood test for " + patientName);
30 | }
31 |
32 | public void treatPatient(String patientName) {
33 | checkUp(patientName);
34 | System.out.println("Doctor " + this.name + " gives prescription to " + patientName);
35 | this.chargePatient();
36 | }
37 |
38 | public void chargePatient() {
39 | System.out.println("Let me charge $100.");
40 | }
41 |
42 | public void displayInfo() {
43 | System.out.println("Doctor " + name + " with licenceId " + licenceId + " has a salary " + salary + " works for "
44 | + hospitalName);
45 | }
46 |
47 | public static void payBills() {
48 | // non-static variables cannot be used
49 | // System.out.println("Doctor " + name);
50 |
51 | // static variables can be used
52 | System.out.println("Everybody pays bills in " + hospitalName);
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/com/review07/HospitalApplication.java:
--------------------------------------------------------------------------------
1 | package com.review07;
2 |
3 | public class HospitalApplication {
4 |
5 | public static void main(String[] args) {
6 |
7 | Doctor.hospitalName = "Hackensack Hospital"; // static variable can be assigned
8 | Doctor.payBills(); // static method can be called
9 | // Doctor.chargePatient(); // non-static is not allowed
10 | // because you have to create the object first
11 |
12 | Doctor doctor1;
13 | doctor1 = new Doctor("John Smith", "12345", 150000);
14 |
15 | // doc1.name = "John Smith";
16 | // doc1.licenceId = "12345";
17 | // doc1.salary = 150000;
18 |
19 | System.out.println("Doctor's name is " + doctor1.name);
20 |
21 | doctor1.displayInfo();
22 | doctor1.treatPatient("Adam Smith");
23 |
24 | Doctor doctor2 = new Doctor("Mehmet Oz", "34567", 400000);
25 | doctor2.displayInfo();
26 |
27 | Doctor doctor3 = new Doctor("Mary James", "68975", 500000, "123 Sessame St");
28 | doctor3.displayInfo();
29 |
30 | Dermatologist dermatologist1 = new Dermatologist("Tom Hanks", "7263", 30000, "D123");
31 |
32 | dermatologist1.chargePatient();
33 | dermatologist1.skinTest();
34 | }
35 |
36 | // HW for Ahmet,
37 | // Do singer
38 | // pop, rock, metal, rap
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/com/review08/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/elionlimanaj1/JavaReviewBatch6/f5349e5f71f55b59e91955e11413f9a3ca6dd5bb/src/com/review08/.DS_Store
--------------------------------------------------------------------------------
/src/com/review08/Abstraction/Belarusian.java:
--------------------------------------------------------------------------------
1 | package com.review08.Abstraction;
2 |
3 | public class Belarusian extends Human{
4 |
5 | public Belarusian(String name) {
6 | super(name);
7 | }
8 |
9 | public void pickMushrooms() {
10 | System.out.println(name + " is picking mushrooms!");
11 | }
12 |
13 | @Override
14 | public void talk() {
15 | System.out.println(name + " vitaju!");
16 | }
17 | }
--------------------------------------------------------------------------------
/src/com/review08/Abstraction/Human.java:
--------------------------------------------------------------------------------
1 | package com.review08.Abstraction;
2 |
3 | public abstract class Human {
4 | String name;
5 | static String planet;
6 |
7 | public Human(String name) {
8 | this.name = name;
9 | }
10 |
11 | public abstract void talk();// unimplemented
12 |
13 | public void sleep() {
14 | // implemented
15 | System.out.println("All human sleep the same.");
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/com/review08/Abstraction/Turkish.java:
--------------------------------------------------------------------------------
1 | package com.review08.Abstraction;
2 |
3 | public class Turkish extends Human {
4 |
5 | public Turkish(String name) {
6 | super(name);
7 | }
8 |
9 | public void makeBaklava() {
10 | System.out.println("I am making baklava");
11 | }
12 |
13 | @Override
14 | public void talk() {
15 | System.out.println(name + " merhaba diyor!");
16 | }
17 | }
--------------------------------------------------------------------------------
/src/com/review08/Abstraction/World.java:
--------------------------------------------------------------------------------
1 | package com.review08.Abstraction;
2 |
3 | public class World {
4 |
5 | public static void main(String[] args) {
6 | Human h1 = new Turkish("Turker"); // upcasting
7 | h1.talk();
8 | h1.sleep();
9 |
10 | Human h2 = new Belarusian("Vitali"); // upcasting
11 | h2.talk();
12 | h2.sleep();
13 |
14 | // h2.pickMushrooms();
15 | Belarusian belarus = (Belarusian) h2;
16 | belarus.pickMushrooms();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/com/review08/Abstraction2/Apple.java:
--------------------------------------------------------------------------------
1 | package com.review08.Abstraction2;
2 |
3 | public class Apple extends Fruit implements Peelable, Washable {
4 |
5 | public Apple(String color) {
6 | super(color);
7 | }
8 |
9 | public void eat() {
10 | System.out.println("Eating the apple");
11 | }
12 |
13 | @Override
14 | public void peel() {
15 | System.out.println("Let's peel the apple");
16 | }
17 |
18 | @Override
19 | public void wash() {
20 | System.out.println("Let's wash the apple");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/com/review08/Abstraction2/Crackable.java:
--------------------------------------------------------------------------------
1 | package com.review08.Abstraction2;
2 |
3 | public interface Crackable {
4 |
5 | void crack(); // by default it is public abstract
6 | }
7 |
--------------------------------------------------------------------------------
/src/com/review08/Abstraction2/Fruit.java:
--------------------------------------------------------------------------------
1 | package com.review08.Abstraction2;
2 |
3 | public abstract class Fruit {
4 | String color;
5 |
6 | public Fruit(String color) {
7 | this.color = color;
8 | }
9 |
10 | public abstract void eat();
11 | }
12 |
--------------------------------------------------------------------------------
/src/com/review08/Abstraction2/FruitDemo.java:
--------------------------------------------------------------------------------
1 | package com.review08.Abstraction2;
2 |
3 | public class FruitDemo {
4 | public static void main(String[] args) {
5 | //Peelable p1 = new Apple("Yellow");
6 |
7 | Fruit f1 = new Apple("Red");
8 | f1.eat();
9 | // f1.peel();
10 |
11 | Apple a1 = (Apple) f1;
12 | a1.peel();
13 | a1.wash();
14 |
15 | System.out.println();
16 | Orange o1 = new Orange("Orange");
17 | o1.eat();
18 |
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/com/review08/Abstraction2/Orange.java:
--------------------------------------------------------------------------------
1 | package com.review08.Abstraction2;
2 |
3 | public class Orange extends Fruit implements Peelable {
4 |
5 | public Orange(String color) {
6 | super(color);
7 | }
8 |
9 | public void eat() {
10 | peel();
11 | System.out.println("Eating the orange");
12 | }
13 |
14 | @Override
15 | public void peel() {
16 | System.out.println("Let's peel the orange");
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/com/review08/Abstraction2/Peelable.java:
--------------------------------------------------------------------------------
1 | package com.review08.Abstraction2;
2 |
3 | public interface Peelable {
4 |
5 | //interfaces cannot have constructor
6 |
7 | public abstract void peel(); // unimplemented
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/src/com/review08/Abstraction2/Walnut.java:
--------------------------------------------------------------------------------
1 | package com.review08.Abstraction2;
2 |
3 | public class Walnut extends Fruit implements Crackable {
4 |
5 | public Walnut(String color) {
6 | super(color);
7 | }
8 |
9 | @Override
10 | public void crack() {
11 | System.out.println("Let's crack the walnut");
12 | }
13 |
14 | @Override
15 | public void eat() {
16 | System.out.println("Let's eat the walnut");
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/com/review08/Abstraction2/Washable.java:
--------------------------------------------------------------------------------
1 | package com.review08.Abstraction2;
2 |
3 | public interface Washable {
4 |
5 | public abstract void wash();
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/src/com/review08/Polymorphism/Belarusian.java:
--------------------------------------------------------------------------------
1 | package com.review08.Polymorphism;
2 |
3 | public class Belarusian extends Human{
4 |
5 | public Belarusian(String name) {
6 | super(name);
7 | }
8 |
9 | @Override
10 | public void talk() {
11 | System.out.println(name + " vitaju!");
12 | }
13 |
14 | public void pickMushrooms() {
15 | System.out.println(name + " is picking mushrooms!");
16 | }
17 | }
--------------------------------------------------------------------------------
/src/com/review08/Polymorphism/Human.java:
--------------------------------------------------------------------------------
1 | package com.review08.Polymorphism;
2 |
3 | public class Human {
4 | String name;
5 | static String planet;
6 |
7 | public Human(String name) {
8 | this.name = name;
9 | }
10 |
11 | public void talk() {
12 | System.out.println(name + " says hi there!");
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/com/review08/Polymorphism/Turkish.java:
--------------------------------------------------------------------------------
1 | package com.review08.Polymorphism;
2 |
3 | public class Turkish extends Human {
4 |
5 | public Turkish(String name) {
6 | super(name);
7 | }
8 |
9 | @Override
10 | public void talk() {
11 | System.out.println(name + " merhaba diyor!");
12 | }
13 |
14 | public void makeBaklava() {
15 | // this two are the same
16 | // this.talk();
17 | // talk();
18 |
19 | // super.talk();
20 | System.out.println("I am making baklava");
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/com/review08/Polymorphism/World.java:
--------------------------------------------------------------------------------
1 | package com.review08.Polymorphism;
2 |
3 | public class World {
4 |
5 | public static void main(String[] args) {
6 | Human.planet = "World";
7 |
8 | Human h1 = new Human("Turker");
9 | System.out.println("The best student is " + h1.name);
10 |
11 | Human h2 = new Human("Gulbahar");
12 |
13 | System.out.println(h2.name + " lives in " + Human.planet);
14 |
15 | System.out.println(h1.name + " lives in " + Human.planet);
16 |
17 | Human t1 = new Turkish("Ali");
18 | System.out.println(t1.name + " lives in " + Human.planet);
19 |
20 | System.out.println("---Now people are talking---");
21 |
22 | // upcasting/widening/done implicitly
23 | Human b1 = new Belarusian("Vitali");
24 | b1.talk();
25 | // bela.pickMushrooms();
26 |
27 | // downcasting/narrowing/done explicitly
28 | Belarusian bela = (Belarusian) b1;
29 | bela.pickMushrooms();
30 |
31 | // cannot convert/cast Vilati into Turkish
32 | // will throw an exception
33 | // Turkish tur = (Turkish) b1;
34 |
35 | h1.talk();
36 | h2.talk();
37 | t1.talk();
38 | b1.talk();
39 |
40 | System.out.println("-----purpose of upcasting-----");
41 | // purpose of upcasting
42 | Human[] people = new Human[6];
43 | people[0] = h1;
44 | people[1] = h2;
45 | people[2] = t1;
46 | people[3] = b1;
47 | people[4] = new Turkish("Veli"); // upcasting
48 | people[5] = new Belarusian("Olga"); // upcasting
49 |
50 | for (Human person : people) {
51 | person.talk();
52 |
53 | if (person instanceof Belarusian) {
54 | // if the object is of type Belarusian
55 | Belarusian belarus = (Belarusian) person;
56 | belarus.pickMushrooms();
57 | } else if (person instanceof Turkish) {
58 | // if the object is of type Turkish
59 | Turkish turk = (Turkish) person;
60 | turk.makeBaklava();
61 | }
62 | }
63 |
64 | }
65 | }
--------------------------------------------------------------------------------
/src/com/review09/CollectionIntro.java:
--------------------------------------------------------------------------------
1 | package com.review09;
2 |
3 | import java.util.*;
4 |
5 | public class CollectionIntro {
6 | public static void main(String[] args) {
7 | List africa = new LinkedList<>();
8 | africa.add("Tunisia");
9 | africa.add("Morocco");
10 | africa.add("Kenya");
11 | africa.add("Algeria");
12 | africa.add(2, "Egypt");
13 |
14 | // 1st way
15 | List africa2 = new ArrayList(africa); // I created a filled list
16 | System.out.println(africa2);
17 |
18 | // 2nd way
19 | List africa3 = new ArrayList();// I created an empty list
20 | africa3.addAll(africa);
21 | System.out.println(africa3);
22 |
23 | System.out.println(africa);
24 |
25 | List europe = new ArrayList<>(); // empty arraylist
26 |
27 | List asia = null; // we don't have an object yet
28 | asia = new ArrayList<>(); // I created a list, but it is empty!!!
29 |
30 | boolean empty = asia.isEmpty();
31 | System.out.println("Asia is empty: " + empty);
32 |
33 | asia.add("China");
34 | asia.add("Tajikistan");
35 | asia.add("Japan");
36 | asia.add("Turkey");
37 | asia.add("China");
38 | asia.add("Nepal");
39 | asia.add("Japan");
40 |
41 | System.out.println(asia);
42 |
43 | System.out.println("Europe size is " + europe.size());
44 | System.out.println("Europe is empty: " + europe.isEmpty());
45 |
46 | europe.add("Albania");
47 | europe.add("France");
48 | europe.add("Spain");
49 | europe.add("Portugal");
50 | europe.add("Turkey");
51 |
52 | europe.add(2, "Germany");
53 |
54 | System.out.println("Europe size is " + europe.size());
55 | System.out.println(europe);
56 |
57 | europe.remove("Turkey");
58 |
59 | System.out.println("Europe size is " + europe.size());
60 | System.out.println("Europe is empty: " + europe.isEmpty());
61 |
62 | // System.out.println("After Corona");
63 | // europe.clear();
64 |
65 | System.out.println("---Iterate/Loop---");
66 | // 1st way
67 | for (int i = 0; i < europe.size(); i++) {
68 | String country = europe.get(i);
69 | System.out.print(country + " ");
70 | }
71 | System.out.println();
72 |
73 | // 2nd way
74 | for (String country : europe) {
75 | System.out.print(country + " ");
76 | }
77 | System.out.println();
78 |
79 | // 3rd way
80 | Iterator it = europe.iterator();
81 | // it.next(); // will return the next element from the collection
82 | // it.hasNext(); // will return true/false
83 | // it.remove(); //will remove the element while iterating
84 |
85 | String country1 = it.next();
86 | String country2 = it.next();
87 | String country3 = it.next();
88 | String country4 = it.next();
89 | String country5 = it.next();
90 | if (it.hasNext()) {// this is a safe check
91 | String country6 = it.next();
92 | }
93 | System.out.println(country1 + " " + country2 + " " + country3);
94 |
95 | Iterator it2 = europe.iterator();
96 | while (it2.hasNext()) { // As long as there is a next element. This will NOT move the cursor
97 | String country = it2.next(); // Get the next element. This will move the cursor
98 | System.out.print(country + " ");
99 | }
100 | System.out.println();
101 |
102 | }
103 |
104 | // HW for Sarmed and everyone
105 | // Add countries into Asia, add duplicates. I did it for you :)
106 | // Iterate the Asia list and remove duplicates
107 | // hint: you can create a new List
108 | // copy from asia into new list,
109 | // but first check if the list CONTAINS the country
110 | }
111 |
--------------------------------------------------------------------------------
/src/com/review09/Phone.java:
--------------------------------------------------------------------------------
1 | package com.review09;
2 |
3 | public class Phone {
4 | // private variables
5 | private String serialNumber;
6 | private String brand;
7 | private String password;
8 |
9 | // public variable
10 | public double price;
11 |
12 | public Phone(String serialNumber, String brand, String password) {
13 | this.serialNumber = serialNumber;
14 | this.brand = brand;
15 | this.password = password;
16 | }
17 |
18 | public void displayInfo() {
19 | System.out.println("This a " + this.brand + " phone with serial number " + serialNumber);
20 | System.out.println("It costs $" + price);
21 | }
22 |
23 | // Getters and Setters
24 |
25 | // I will give you the serial number
26 | // if you give me the correct password
27 | public String getSerialNumber(String password) {
28 | String result = "";
29 |
30 | if (this.password.equals(password)) {
31 | result = serialNumber;
32 | } else {
33 | result = "Invalid Access!!!";
34 | }
35 |
36 | return result;
37 | }
38 |
39 | // You will be able to change the serial number
40 | // only if you give me a 7-character string
41 | public void setSerialNumber(String serialNumber) {
42 | if (serialNumber.length() == 7) {
43 | this.serialNumber = serialNumber;
44 | }
45 | }
46 |
47 | // Brand is view only
48 | public String getBrand() {
49 | return brand;
50 | }
51 |
52 | // HW for Sarmed.
53 | // Change the setSerialNumber
54 | // He/she needs to provide the correct password
55 | // and to be a 7-character string
56 | }
--------------------------------------------------------------------------------
/src/com/review09/PhoneDemo.java:
--------------------------------------------------------------------------------
1 | package com.review09;
2 |
3 | public class PhoneDemo {
4 | public static void main(String[] args) {
5 | Phone p1 = new Phone("2345678", "iPhone", "password123");
6 | p1.price = 1200;
7 | System.out.println("The price of the phone is " + p1.price);
8 |
9 | p1.displayInfo();
10 |
11 | System.out.println("--------Getting the brand--------");
12 | String brand = p1.getBrand();
13 |
14 | //I cannot SET the brand because there is no setter method
15 |
16 | System.out.println("--------Getting serial number--------");
17 | String serial = p1.getSerialNumber("Elion123");
18 | System.out.println(serial);
19 |
20 | serial = p1.getSerialNumber("password123");
21 | System.out.println(serial);
22 |
23 | System.out.println("--------Setting serial number--------");
24 | // p1.serialNumber = "bla bla bla";
25 | p1.setSerialNumber("bla bla bla");
26 | p1.setSerialNumber("SR12345");
27 |
28 | p1.displayInfo();
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/com/review09/WrapperDemo.java:
--------------------------------------------------------------------------------
1 | package com.review09;
2 |
3 | public class WrapperDemo {
4 |
5 | public static void main(String[] args) {
6 |
7 | int int1 = 5;
8 | Integer integer1 = new Integer(int1); // Boxing
9 | int int2 = integer1.intValue(); // Unboxing
10 |
11 | System.out.println(int2);
12 |
13 | int int3 = 10;
14 | // Integer integer3 = new Integer(int3);
15 | Integer integer3 = int3; // Auto-boxing, Auto-wrapping, Auto-converting
16 | // int int4 = integer3.intValue();
17 | int int4 = integer3; // Auto-unboxing, Auto-unwrapping, Auto-converting
18 |
19 | // Double Wrapper class
20 | double d1 = 3;
21 | Double d2 = d1; // Auto boxing
22 |
23 | // it does not access it in one step
24 | // Double d3 = 3;
25 | Double d4 = 3.0; // Auto boxing
26 |
27 | double d5 = d4.doubleValue(); // 1st way, long way; unboxing
28 | double d6 = d4; // 2nd way, short way; Auto-unboxing
29 |
30 | // For Mohamed
31 | // Boolean is the chocolate with a wrapper
32 | Boolean b1 = new Boolean(true);
33 | // if we need the primitive value we un-box
34 | // boolean is the chocolate without the wrapper
35 | boolean b2 = b1.booleanValue();
36 |
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/com/review10/MapIntro.java:
--------------------------------------------------------------------------------
1 | package com.review10;
2 |
3 | import java.util.*;
4 | import java.util.Map.Entry;
5 |
6 | public class MapIntro {
7 | // Map
8 | // HashMap LinkedHashMap TreeMap HashTable
9 |
10 | public static void main(String[] args) {
11 | Map phoneBook = new HashMap<>();
12 | phoneBook.put(123456789, "John Smith");
13 | phoneBook.put(234567890, "James London");
14 | phoneBook.put(345678901, "Rohani Smith");
15 | phoneBook.put(456789012, "Donald Trump");
16 | phoneBook.put(111111111, "Obama");
17 | phoneBook.put(687945623, "Brad Pitt");
18 | phoneBook.put(444444444, "John Smith");
19 |
20 | // It will override Rohani Smith
21 | phoneBook.put(345678901, "Julia Roberts");
22 |
23 | String name = phoneBook.get(687945623);
24 | System.out.println(name + " is calling!");
25 |
26 | String name2 = phoneBook.get(5555);
27 | System.out.println(name2 + " is calling");
28 |
29 | boolean contains = phoneBook.containsKey(5555);
30 | System.out.println("5555 is in the map: " + contains);
31 |
32 | boolean contains2 = phoneBook.containsValue("Julia Roberts");
33 | System.out.println("Julia Roberts is in my contact list: " + contains2);
34 |
35 | // Will remove Trump from my list
36 | phoneBook.remove(456789012);
37 |
38 | System.out.println(phoneBook);
39 |
40 | phoneBook.isEmpty();
41 |
42 | //////////////////////////////////////////////
43 | // Let's get all the keys and store them in a Set
44 | System.out.println("--------keySet()--------");
45 | Set keys = phoneBook.keySet();
46 | Iterator it = keys.iterator();
47 | while (it.hasNext()) {
48 | Integer key = it.next();
49 | String value = phoneBook.get(key);
50 | System.out.println(key + "->" + value);
51 | }
52 |
53 | // Let's get all the values and store them in a Collection
54 | System.out.println("--------values()--------");
55 | Collection values = phoneBook.values();
56 | for (String value : values) {
57 | System.out.println(value);
58 | }
59 |
60 | // Let's get all the entries and store them in Set
61 | System.out.println("--------entrySet()--------");
62 | Set> entries = phoneBook.entrySet();
63 |
64 | // 1st way, using enhanced for loop
65 | for (Entry entry : entries) {
66 | // System.out.println(entry);
67 |
68 | // Integer key = entry.getKey();
69 | // String value = entry.getValue();
70 | // System.out.println(key + " ---> " + value);
71 |
72 | System.out.println(entry.getKey() + " ---> " + entry.getValue());
73 | }
74 |
75 | System.out.println("--------iterator--------");
76 | // 2nd way, using iterator
77 | Iterator> entryIt = entries.iterator();
78 | while (entryIt.hasNext()) {
79 | Entry entry = entryIt.next();
80 | System.out.println(entry.getKey() + ":" + entry.getValue());
81 | }
82 | }
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/src/com/review10/SetIntro.java:
--------------------------------------------------------------------------------
1 | package com.review10;
2 |
3 | import java.util.*;
4 |
5 | public class SetIntro {
6 |
7 | public static void main(String[] args) {
8 | // Collection
9 | // List | Set | Queue
10 | // ArrayList LinkedList | HashSet LinkedHashSet TreeSet |
11 |
12 | Set africaLinked = new LinkedHashSet<>();
13 | africaLinked.add("Tunisia");
14 | africaLinked.add("Morocco");
15 | africaLinked.add("Kenya");
16 |
17 | // Will not add in the Set, because it already exists
18 | africaLinked.add("Kenya");
19 |
20 | africaLinked.add("Algeria");
21 |
22 | // You cannot add with an index!!!
23 | // africa.add(2, "Egypt");
24 |
25 | System.out.println("LinkedHashSet " + africaLinked);
26 |
27 | Set africa2 = new HashSet<>(africaLinked);
28 | System.out.println("HashSet " + africa2);
29 |
30 | Set africa3 = new TreeSet<>(africaLinked);
31 | System.out.println("TreeSet " + africa3);
32 |
33 | int size = africa2.size();
34 | boolean contains = africa2.contains("Kenya");
35 | boolean isEmpty = africa2.isEmpty();
36 | boolean ableToRemove = africa2.remove("Algeria");
37 |
38 | // You are not able to remove by index
39 | // africa2.get(2);
40 |
41 | // 1st way, DOES NOT work in a set
42 | // for (int i = 0; i < africa2.size(); i++) {
43 | // String country = africa2.get(i);
44 | // System.out.print(country + " ");
45 | // }
46 |
47 | // 2nd way, enhanced/advanced for loop
48 | System.out.println("---enhanced/advanced for loop---");
49 | for (String country : africa2) {
50 | System.out.print(country + " ");
51 | }
52 | System.out.println();
53 |
54 | // 3rd way, using iterator
55 | System.out.println("---using iterator---");
56 | Iterator it = africa2.iterator();
57 | while (it.hasNext()) {
58 | String country = it.next();
59 | System.out.print(country + " ");
60 | }
61 | System.out.println();
62 |
63 | // 1. List preserves insertion order, BUT Set doesn't
64 | // 2. List contains duplicates, BUT Set contains unique objects
65 |
66 | Set europe = new HashSet<>();
67 | europe.add("Albania");
68 | europe.add("France");
69 | europe.add(null);
70 | europe.add("Spain");
71 | europe.add("Portugal");
72 | europe.add("Spain");
73 | europe.add(null);
74 |
75 | System.out.println(europe);
76 |
77 | // Collection Framework
78 | // Collection Interface
79 | // Collections is a class
80 | String minimum = Collections.min(africa2);
81 | System.out.println(minimum);
82 |
83 | Set numbers = new HashSet<>();
84 | numbers.add(56);
85 | numbers.add(23);
86 | numbers.add(49);
87 | numbers.add(93);
88 | numbers.add(17);
89 |
90 | // for (Integer obj : numbers) {
91 | // System.out.println(obj);
92 | // }
93 |
94 | Integer minInt = Collections.min(numbers);
95 | Integer maxInt = Collections.max(numbers);
96 | System.out.println("Numbers from " + minInt + " to " + maxInt);
97 | }
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/src/com/review10/WorldMap.java:
--------------------------------------------------------------------------------
1 | package com.review10;
2 |
3 | import java.util.*;
4 | import java.util.Map.Entry;
5 |
6 | public class WorldMap {
7 |
8 | public static void main(String[] args) {
9 | Map europe = new HashMap<>();
10 | europe.put("France", "Paris");
11 | europe.put("Italy", "Rome");
12 | europe.put("Germany", "Berlin");
13 | System.out.println(europe);
14 |
15 | Set> entries = europe.entrySet();
16 | System.out.println(entries);
17 |
18 | Map africa = new HashMap<>();
19 | africa.put("Morocco", "Rabat");
20 | africa.put("Egypt", "Cairo");
21 | africa.put("Tunisia", "Tunis");
22 | System.out.println(africa);
23 |
24 | Map asia = new HashMap<>();
25 | asia.put("China", "Beijing");
26 | asia.put("Turkmenistan", "Ashgabat");
27 | asia.put("Japan", "Tokyo");
28 | System.out.println(asia);
29 |
30 | // HW1 iterate europe by getting keys.
31 | // HW2 iterate africa by getting entries.
32 | // HW3 iterate asia by getting values.
33 |
34 | System.out.println("-----------WORLD------------");
35 | List