├── Day1 ├── VariableDataType.class ├── VariableDataType.java ├── helloworld.class └── helloworld.java ├── Day10 ├── BreakContinue.class ├── BreakContinue.java ├── LoopInJava.class └── LoopInJava.java ├── Day11 ├── Array.class ├── Array.java ├── Practice.class └── Practice.java ├── Day12 ├── ArrayLoop.class ├── ArrayLoop.java ├── MultiDmArray.class └── MultiDmArray.java ├── Day13 ├── Practice.class └── Practice.java ├── Day14 ├── Methods.class └── Methods.java ├── Day15 ├── MethodOverloading.class └── MethodOverloading.java ├── Day16 ├── Practice.class ├── Practice.java ├── Recursion.class ├── Recursion.java ├── VariableArgument.class └── VariableArgument.java ├── Day17 ├── CustomClass.class ├── CustomClass.java ├── Employee.class ├── OOP.java ├── Practice.class └── Practice.java ├── Day18 ├── AccessModGetSet.class ├── AccessModGetSet.java ├── Devv.class ├── Employee.class ├── Practice.class ├── Practice.java ├── Square.class ├── cellPhone.class └── myEmployee.class ├── Day19 ├── Constructors.class ├── Constructors.java ├── RockPprscr.class ├── RockPprscr.java └── myEmployee.class ├── Day2 ├── Literal.class ├── Literal.java ├── UserInput.class ├── UserInput.java └── tempCodeRunnerFile.java ├── Day20 ├── Base.class ├── Cylinder.class ├── Derived.class ├── Inheritance.class ├── Inheritance.java ├── Practice.class ├── Practice.java └── Rectangle.class ├── Day21 ├── Base1.class ├── ChildOfDerived.class ├── ConsInInheritance.class ├── ConsInInheritance.java ├── Derived.class ├── Derived1.class ├── DoClass.class ├── EkClass.class ├── ThisSuper.class └── ThisSuper.java ├── Day22 ├── A.class ├── B.class ├── DynMethodDispatch.class ├── DynMethodDispatch.java ├── MethodOverriding.class ├── MethodOverriding.java ├── One.class └── Two.class ├── Day23 ├── Game.class ├── GuesTheNum.class └── GuesTheNum.java ├── Day24 ├── AbstractClassMethod.class ├── AbstractClassMethod.java ├── Child.class ├── Child2.class └── Parent.class ├── Day25 ├── Bicycle.class ├── ElectricBicycle.class ├── HornBicycle.class ├── Interfaces.class └── Interfaces.java ├── Day26 ├── Camera.class ├── CellPhone.class ├── MoreInterfaces.class ├── MoreInterfaces.java ├── SmartPhone.class └── Wifi.class ├── Day27 ├── InheritanceInterfaces.class ├── InheritanceInterfaces.java ├── MySample.class ├── Polymorphism │ ├── Camera.class │ ├── CellPhone.class │ ├── Polymorphism.class │ ├── Polymorphism.java │ ├── SmartPhone.class │ └── Wifi.class ├── childSample.class └── sampleInterface.class ├── Day28 ├── BasicAnimal.class ├── FountainPen.class ├── Human.class ├── Monkey.class ├── Pen.class ├── Practice.class └── Practice.java ├── Day29 ├── CompInter │ ├── CompInter.class │ └── CompInter.java ├── Package.java ├── Package1.java ├── Package2.java └── common │ ├── Package.class │ ├── Package1.class │ └── Package2.class ├── Day3 └── Practice.java ├── Day30 ├── AccessModi.class ├── AccessModi.java ├── C1.class ├── C2.class └── Practice │ ├── Practice.java │ ├── Practice2.java │ ├── Practice3.class │ ├── Practice3.java │ ├── c1.class │ ├── calc │ ├── Calculator.class │ ├── HyCalculator.class │ ├── Practice.class │ └── ScCalculator.class │ └── pack │ └── pack1 │ └── pack2 │ ├── Calculator.class │ ├── HyCalculator.class │ ├── Practice2.class │ └── ScCalculator.class ├── Day31 ├── ExtendThread.class ├── ExtendThread.java ├── MultiThreading.class ├── MultiThreading.java ├── MyThread.class ├── MyThread2.class ├── RunnableThread.class ├── RunnableThread2.class ├── ThreadRunnable.class └── ThreadRunnable.java ├── Day32 ├── ConsFromThread.java ├── LifeCycle.java └── com │ ├── ConsFromThread.class │ ├── LifeCycle.class │ ├── MyThr.class │ ├── RunnableThread.class │ └── RunnableThread2.class ├── Day33 ├── Practice.java ├── ThreadMethods.java ├── ThreadPriorities.java └── com │ ├── MyThread.class │ ├── MyThread1.class │ ├── MyThread2.class │ ├── Practice.class │ ├── PracticeA.class │ ├── PracticeB.class │ ├── ThreadMethods.class │ └── ThreadPriorities.class ├── Day34 ├── Circle.java ├── Cylinder.java ├── Rect.java ├── Shape.java ├── Sphere.java ├── Square.java └── com │ └── shape │ ├── Circle.class │ ├── Cylinder.class │ ├── Rect.class │ ├── Shape.class │ ├── Sphere.class │ └── Square.class ├── Day35 ├── ErrorDemo.java ├── ErrorException.java └── com │ ├── ErrorDemo.class │ └── ErrorException.class ├── Day36 ├── HandleException.java ├── NestedTryCatch.java └── com │ ├── HandleException.class │ └── NestedTryCatch.class ├── Day37 ├── ExceptionClass.java ├── ThrowVsThrows.java └── com │ ├── ExceptionClass.class │ ├── MyException.class │ ├── NegativeExceptions.class │ └── ThrowVsThrows.class ├── Day38 ├── FinallyBlock.java ├── Practice.java └── com │ ├── FinallyBlock.class │ └── Practice.class ├── Day39 ├── CollectionFramework.java └── CollectionsHierarchy.java ├── Day4 ├── AssociativityJava.class ├── AssociativityJava.java ├── Operators.java └── Type_Conversion_Precedence_and_Associativity__8oLmD9g.jpg ├── Day40 ├── ArrayDequeJava.java ├── ArrayListJava.java ├── LinkedListJava.java └── com │ ├── ArrayDequeJava.class │ ├── ArrayListJava.class │ └── LinkedListJava.class ├── Day41 ├── Day41 │ └── HashMapJava.class ├── HashMapJava.java ├── HashSetJava.java ├── HashingTechn.java └── com │ ├── Book.class │ ├── HashMap.class │ ├── HashMapJava.class │ └── HashSetJava.class ├── Day42 ├── CalendarClass.java ├── DateClass.java ├── DateTime.java ├── GregrianCal.java └── com │ ├── CalendarClass.class │ ├── DateClass.class │ ├── DateTime.class │ └── GregrianCal.class ├── Day43 ├── DTFormatter.java ├── Practice.java ├── PracticeCalc.java ├── TimeAPI.java └── com │ ├── CannotDivideByZero.class │ ├── CustomCalculator.class │ ├── DTFormatter.class │ ├── InvalidInputException.class │ ├── Practice.class │ ├── PracticeCalc.class │ └── TimeAPI.class ├── Day5 ├── Practice.class ├── Practice.java ├── ResultingDataType.class └── ResultingDataType.java ├── Day6 ├── StringMethod.class ├── StringMethod.java ├── Strings.class └── Strings.java ├── Day7 ├── PracticeDay.class └── PracticeDay.java ├── Day8 ├── ControlFlow.class ├── ControlFlow.java ├── Relational.class ├── Relational.java ├── SwitchJava.class └── SwitchJava.java ├── Day9 ├── Practice.class └── Practice.java ├── Project ├── 001 Clock │ ├── DigitalClock.class │ ├── DigitalClock.java │ └── MyWindow.class └── 002 GuessingGame │ ├── Game.java │ ├── GuessingGame.java │ └── com │ ├── Game.class │ └── GenNumber.class └── README.md /Day1/VariableDataType.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day1/VariableDataType.class -------------------------------------------------------------------------------- /Day1/VariableDataType.java: -------------------------------------------------------------------------------- 1 | public class VariableDataType { 2 | public static void main(String[] args) { 3 | System.out.print("Sum of three number:"); 4 | int num1 = 3; 5 | int num2 = 4; 6 | int num3 = 6; 7 | System.out.println(num1+num2+num3); 8 | } 9 | } 10 | // println add new line 11 | // print = no new line 12 | 13 | 14 | // int num = 10 15 | // int = data type 16 | // num = variable name 17 | // 10 = value 18 | 19 | // 1- whitespace not allowed = all in 20 | // 2- no keyword allowed = void 21 | // 3- camelcase, uppercase = allIn, ALLIN ( they are different ) 22 | // 4- cant start with number = 1ar but ar1 is valid 23 | // 5- data type declier first = int num 24 | 25 | // Into Data Type ==> 8 Primitive dta type 26 | // ------------------ 27 | // byte --> value range -128 to 127 28 | // takes 1 byte 29 | // default value is 0 30 | // ------------------ 31 | // Short --> value range from -(2^16)/2 to (2^16)/2 -1 32 | // takes 2 bytes 33 | // default value is 0 34 | // ------------------ 35 | // int --> value range from -(2^32)/2 to (2^32)/2 -1 36 | // takes 4 bytes 37 | // default value is 0 38 | // ------------------ 39 | // float --> value range from (docs) 40 | // takes 4 bytes 41 | // default value is 0.0f 42 | // ------------------ 43 | // long --> value range from -(2^64)/2 to (2^64)/2 -1 44 | // takes 8 bytes 45 | // default value is 0 46 | // ------------------ 47 | // double --> value range from (docs) 48 | // takes 8 bytes 49 | // default value is 0.od 50 | // ------------------ 51 | // Short --> value range from 0 to 65535 52 | // takes 2 bytes 53 | // default value is "\/uoooo" 54 | // ------------------ 55 | // boolean --> value true or false 56 | // depends on jvm 57 | // default value is false 58 | // ------------------ 59 | -------------------------------------------------------------------------------- /Day1/helloworld.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day1/helloworld.class -------------------------------------------------------------------------------- /Day1/helloworld.java: -------------------------------------------------------------------------------- 1 | public class HelloWorld { 2 | public static void main(String[] args) { 3 | System.out.println("Hello World!"); 4 | } 5 | } 6 | 7 | // class name should be PascalConvention 8 | // function name should be camelCase 9 | // ImLearning - PascalCase 10 | // imLearning - camelCase 11 | 12 | // Data types 13 | // Primitive=> int, byte, long, float, short, bool, char 14 | // Non Primitive => ? -------------------------------------------------------------------------------- /Day10/BreakContinue.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day10/BreakContinue.class -------------------------------------------------------------------------------- /Day10/BreakContinue.java: -------------------------------------------------------------------------------- 1 | public class BreakContinue { 2 | public static void main(String[] args) { 3 | 4 | // for (int j = 0; j < 10; j++) { 5 | // System.out.println(j); 6 | 7 | // // end loop when j equal 3 8 | // if (j == 3) { 9 | // System.out.println("End Loop"); 10 | // break; 11 | // } 12 | // } 13 | 14 | // int i = 3; 15 | // while (i < 10) { 16 | // if (i == 7) { 17 | // System.out.println("End Loop"); 18 | // break; 19 | // } 20 | // System.out.println(i); 21 | // i++; 22 | // } 23 | 24 | // Continue 25 | // for (int j = 0; j < 10; j++) { 26 | // if (j == 7) { 27 | // System.out.println("Ignore below code"); 28 | // continue; 29 | // } 30 | // System.out.println(j); 31 | // } 32 | 33 | int i = 2; 34 | do { 35 | i++; 36 | if (i == 4) { 37 | System.out.println("Ignore 4"); 38 | continue; 39 | } 40 | System.out.println(i); 41 | }while (i < 10); 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Day10/LoopInJava.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day10/LoopInJava.class -------------------------------------------------------------------------------- /Day10/LoopInJava.java: -------------------------------------------------------------------------------- 1 | public class LoopInJava { 2 | public static void main(String[] args) { 3 | int i = 0; 4 | 5 | // While Loop 6 | // while (i < 5) { 7 | // System.out.println(i); 8 | // i++; 9 | // } 10 | // while (true) { 11 | // System.out.println(i); 12 | // i++; 13 | // } 14 | 15 | // Do While Loop 16 | // run at leat 1 time, even condition is false 17 | // do{ 18 | // System.out.println(i); 19 | // i++; 20 | // }while (i < 5); 21 | 22 | // For loop 23 | // execute a piece of code for specific time 24 | // for (int x = 0; x < 5; x++) { 25 | // System.out.println(x); 26 | // } 27 | // even odd output 28 | for (int j = 0; j < 10; j++) { 29 | System.out.println(j++); 30 | } 31 | } 32 | } 33 | /* 34 | * LOOP TYPE 35 | * --------- 36 | * Primary thre type 37 | * -> While Loop 38 | * -> Do-While Loop 39 | * -> For Loop 40 | * 41 | * No description needed as we all already know how they works. 42 | */ -------------------------------------------------------------------------------- /Day11/Array.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day11/Array.class -------------------------------------------------------------------------------- /Day11/Array.java: -------------------------------------------------------------------------------- 1 | 2 | public class Array { 3 | public static void main(String[] args) { 4 | // int[] marks = new int[5]; 5 | // marks[0] = 0; 6 | // marks[1] = 10; 7 | // marks[2] = 20; 8 | // marks[3] = 30; 9 | // marks[4] = 40; 10 | // marks[4] = 60; // overwrite 11 | // marks[5] = 60; 12 | int[] marks = { 1, 2, 3, 4, 6, 7 }; 13 | System.out.println(marks); 14 | } 15 | } 16 | 17 | /* 18 | * Array 19 | * ----- 20 | * Array is collection of similar type of data 21 | * datatype [] Name 22 | * int [] student = new int [5] 23 | * ......................... 24 | * ....0 1 2 3 4 ........... 25 | * ....[][][][][] <- [] .... 26 | * ......object . . marks .. 27 | * ......................... 28 | * 4 byte of 1 int 29 | * 30 | * Memory Allocation -> new int[n] 31 | * {1, 2,3, 4, 5, 6, 7} 32 | */ -------------------------------------------------------------------------------- /Day11/Practice.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day11/Practice.class -------------------------------------------------------------------------------- /Day11/Practice.java: -------------------------------------------------------------------------------- 1 | public class Practice { 2 | public static void main(String[] args) { 3 | 4 | // practice 1 5 | // int n = 4; 6 | // for (int i = n; i > 0; i--) { 7 | // for (int j = 0; j < i; j++) { 8 | // System.out.print("*"); 9 | // } 10 | // System.out.println("\n"); 11 | // } 12 | 13 | // Practice 2 14 | // int sum = 0; 15 | // int n = 4; 16 | // for (int i = 0; i < n; i++) { 17 | // sum += 2*i; 18 | // } 19 | // System.out.println(sum); 20 | 21 | // Practice 3 22 | // int n = 5; 23 | // for (int i = 1; i <= 10; i++) { 24 | // System.out.printf(n*i+ " "); 25 | // } 26 | 27 | // Practice 4 reverse 28 | // int n = 5; 29 | // for (int i = 10; i >= 0; i--) { 30 | // System.out.printf(n*i+ " "); 31 | // } 32 | 33 | // Practice 5 34 | // int n = 5; 35 | // for (int i = n; i > 0; i--) System.out.println(i * i); 36 | // int fact = 1; 37 | // int i = 1; 38 | // while (i <= n) { 39 | // fact *= i; 40 | // i++; 41 | // } 42 | // System.out.println(fact); 43 | 44 | // Practice 6 45 | int n = 5; 46 | int sum = 0; 47 | for (int i = 1; i <= 10; i++) { 48 | sum += n*i; 49 | } 50 | System.out.println(sum); 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Day12/ArrayLoop.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day12/ArrayLoop.class -------------------------------------------------------------------------------- /Day12/ArrayLoop.java: -------------------------------------------------------------------------------- 1 | import java.nio.channels.AsynchronousByteChannel; 2 | 3 | import org.xml.sax.SAXNotSupportedException; 4 | 5 | public class ArrayLoop { 6 | public static void main(String[] args) { 7 | int[] marks = { 1, 2, 3, 4, 5, 6 }; 8 | float[] marksf = { 1.1f, 2.3f, 5.6f, 12.3f }; 9 | String[] names = { "S", "A", "K", "I", "b" }; 10 | // System.out.println(names); 11 | // System.out.println(marks[3]); 12 | // System.out.println(marksf[3]); 13 | // System.out.println(marks.length); 14 | // System.out.println(marks.length); 15 | 16 | // For Loop 17 | // for (int i = 0; i < names.length; i++) { 18 | // if (names[i] == "b") { 19 | // names[i] = "B"; 20 | // } 21 | // System.out.printf(names[i]); 22 | // } 23 | 24 | // For each loop 25 | for (String i : names) { 26 | if (i == "b") { 27 | i = "B"; 28 | } 29 | System.out.println(i); 30 | } 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Day12/MultiDmArray.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day12/MultiDmArray.class -------------------------------------------------------------------------------- /Day12/MultiDmArray.java: -------------------------------------------------------------------------------- 1 | public class MultiDmArray { 2 | public static void main(String[] args) { 3 | // 2D Array 4 | String[][] twoD; 5 | twoD = new String[2][3]; 6 | twoD[0][0] = "DevvSakib"; 7 | twoD[0][1] = "Frontend"; 8 | twoD[0][2] = "Hi!"; 9 | twoD[1][0] = "Developer"; 10 | twoD[1][1] = "I'm"; 11 | twoD[1][2] = ""; 12 | // System.out.print(twoD[0][2] + " "); 13 | // System.out.print(twoD[1][1] + " "); 14 | // System.out.print(twoD[0][0] + " "); 15 | // System.out.print(twoD[0][1] + " "); 16 | // System.out.print(twoD[1][0] + " "); 17 | // System.out.println(); 18 | for (int i = 0; i < twoD.length; i++) { 19 | for (int j = 0; j < twoD[i].length; j++) { 20 | System.out.print(twoD[i][j]); 21 | System.out.print(" "); 22 | } 23 | } 24 | } 25 | } 26 | 27 | // Multidimentional Array 28 | // Array of Array = array element also array = array of array elements also 29 | // array 3D array -------------------------------------------------------------------------------- /Day13/Practice.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day13/Practice.class -------------------------------------------------------------------------------- /Day13/Practice.java: -------------------------------------------------------------------------------- 1 | public class Practice { 2 | public static void main(String[] args) { 3 | 4 | // Practice 1 5 | // float[] marks = {50.45f, 76.4f,87.56f, 100.0f}; 6 | // float sum = 0; 7 | // for (float f : marks) { 8 | // sum += f; 9 | // } 10 | // System.out.println(sum); 11 | 12 | // Practice 2 13 | // float[] marks = {50.45f, 76.4f,87.56f, 100.0f}; 14 | // float num = 87.556f; 15 | // float num = 87.556f; 16 | // boolean isArray = false 17 | 18 | // Practice 3 19 | // float[] marks = {50.45f, 76.4f,87.56f, 100.0f}; 20 | // float sum = 0; 21 | // for (float f : marks) { 22 | // sum += f; 23 | // } 24 | // sum = sum / marks.length; 25 | // System.out.println(sum); 26 | 27 | // Practice 4 addition of two 2D array 28 | /* 29 | * int[][] mat1 = { 30 | * { 1, 2, 3 }, 31 | * { 4, 5, 6 } }; 32 | * int[][] mat2 = { 33 | * { 3, 4, 5 }, 34 | * { 6, 5, 8 } }; 35 | * int[][] result = { 36 | * { 0, 0, 0 }, 37 | * { 0, 0, 0 } }; 38 | * 39 | * for (int m1 = 0; m1 < mat1.length; m1++) { // row 40 | * for (int i = 0; i < mat1[m1].length; i++) { // column 41 | * result[m1][i] = mat1[m1][i] + mat2[m1][i]; 42 | * System.out.print(result[m1][i] + " "); 43 | * } 44 | * System.out.println(); 45 | * } 46 | */ 47 | 48 | // Practice 4 Reverse array 49 | int[] arr = { 1, 65, 78, 10, -5, 6, 7 }; 50 | int a = Math.floorDiv(arr.length, 2); 51 | int temp; 52 | for (int i = 0; i < a; i++) { 53 | // swap a[i] [l-1-i] 54 | temp = arr[i]; 55 | arr[i] = arr[arr.length - i - 1]; 56 | arr[arr.length - i - 1] = temp; 57 | } 58 | for (int e : arr) { 59 | System.out.println(e); 60 | } 61 | // Practice 5 62 | int max = Integer.MIN_VALUE; 63 | for (int i : arr) { 64 | if (i > max) { 65 | max = i; 66 | } 67 | } 68 | System.out.println(max); 69 | // System.out.println(Integer.MAX_VALUE); 70 | 71 | // Practice 6 72 | boolean isSorted = true; 73 | for (int i = 0; i < arr.length - 1; i++) { 74 | if (arr[i] > arr[i + 1]) { 75 | isSorted = false; 76 | break; 77 | } 78 | } 79 | System.out.println(isSorted); 80 | 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Day14/Methods.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day14/Methods.class -------------------------------------------------------------------------------- /Day14/Methods.java: -------------------------------------------------------------------------------- 1 | public class Methods { 2 | 3 | // Method - static is important, only static method can be called in static 4 | // main. 5 | // static int logic(int a, int b) { 6 | // int c; 7 | 8 | // if (a > b) { 9 | // c = a - b; 10 | // } else { 11 | // c = a + b; 12 | // } 13 | // return c; 14 | // } 15 | int logic(int a, int b) { 16 | int c; 17 | 18 | if (a > b) { 19 | c = a - b; 20 | } else { 21 | c = a + b; 22 | } 23 | return c; 24 | } 25 | 26 | public static void main(String[] args) { 27 | int x, z, y, g,h,j; 28 | x = 10; 29 | y = 5; 30 | g = 11; 31 | h = 3; 32 | Methods obj = new Methods(); // crreating obj, no need static keyw 33 | z = obj.logic(x, y); 34 | j = obj.logic(h, g); 35 | // z = logic(x, y); 36 | System.out.println(z); 37 | System.out.println(j); 38 | } 39 | } 40 | /* 41 | * 42 | * Sometimes our program grows in a size and we want to separate the logic of 43 | * main method to other methods. 44 | * DRY -> Do not Repeat Yourself 45 | * 46 | * A method is a function written into a class. Since Java is an OOP, we need to 47 | * write method inside some class. 48 | * 49 | * dataType name(x, y){ 50 | * .. method here 51 | * } 52 | * 53 | * Calling Method 54 | * A method can be called by creating an object of the class in which method 55 | * exists followed by the method call: 56 | * 57 | * Calc obj = new Calc() // obj creation 58 | * obj.sum(a,b) // called 59 | * 60 | * 61 | * 62 | */ -------------------------------------------------------------------------------- /Day15/MethodOverloading.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day15/MethodOverloading.class -------------------------------------------------------------------------------- /Day15/MethodOverloading.java: -------------------------------------------------------------------------------- 1 | import javax.swing.event.ChangeEvent; 2 | 3 | public class MethodOverloading { 4 | static void tellJoke() { 5 | System.out.println("Hi, I'm not returning anything. I'm void"); 6 | }; 7 | 8 | static void replaceElement(int a) { 9 | a = 100; 10 | } 11 | 12 | static void replaceElement(float[] a) { 13 | a[0] = 90; 14 | } 15 | 16 | // Overloading 17 | static void foo() { 18 | System.out.println("No argument"); 19 | } 20 | 21 | static void foo(int a) { 22 | System.out.println("With argument " + a); 23 | } 24 | 25 | static void foo(int a, int b) { 26 | System.out.println("With Two argument " + a + b); 27 | } 28 | 29 | public static void main(String[] args) { 30 | // float[] marksf = { 1.1f, 2.3f, 5.6f, 12.3f }; 31 | // Case 1 changing integer 32 | // int x = 980; 33 | // replaceElement(x); // no changes 34 | 35 | // Case 2 changing Array 36 | // replaceElement(marksf); // no changes 37 | // System.out.println("The value of x is: " + marksf[0]); 38 | 39 | // Method Overloading 40 | foo(); 41 | foo(30); 42 | foo(30, 90); 43 | // Argument are actuall -> 30, 90 44 | // Parameter -> int a, int b 45 | 46 | }; 47 | }; 48 | 49 | /* 50 | * Void return type 51 | * ---------------- 52 | * When we dont want to return anything from method. use void return type 53 | * Can be access in anywhere in main class(MethodOverloading) 54 | * 55 | * Method Overloading 56 | * ------------------ 57 | * Two or more methods can have same name but different parameters. Such methods 58 | * are overloaded methods. 59 | * 60 | * 1. change perameter 61 | * 62 | */ -------------------------------------------------------------------------------- /Day16/Practice.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day16/Practice.class -------------------------------------------------------------------------------- /Day16/Practice.java: -------------------------------------------------------------------------------- 1 | public class Practice { 2 | 3 | static void foo() { 4 | System.out.println("Hello Foo 1"); 5 | } 6 | 7 | static void foo(int a, int b) { 8 | if (a < b) { 9 | System.out.println("A is small"); 10 | } else { 11 | System.out.println("B is small"); 12 | } 13 | } 14 | 15 | static void foo(int[] ar){ 16 | for (int i : ar) { 17 | if (i == 5) { 18 | System.out.format("Your array contain %d \n", i); 19 | 20 | } 21 | } 22 | } 23 | static void foo(String a){ 24 | if (a.contains("dib")) { 25 | System.out.println(true); 26 | } 27 | else{ 28 | System.out.println("Sorry! This word doesn't exit!"); 29 | } 30 | } 31 | 32 | 33 | public static void main(String[] args) { 34 | // foo(); 35 | // foo(7, 5); 36 | int [] arr = {1,2,3,4,5}; 37 | // foo(arr); 38 | 39 | String name = "DevvSakib"; 40 | // foo(name); 41 | 42 | 43 | 44 | } 45 | } -------------------------------------------------------------------------------- /Day16/Recursion.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day16/Recursion.class -------------------------------------------------------------------------------- /Day16/Recursion.java: -------------------------------------------------------------------------------- 1 | public class Recursion { 2 | // factorial 3 | 4 | static int factorial_interative(int a) { 5 | int fact = 1; 6 | if (a <= 0) { 7 | return 0; 8 | } 9 | for (int i = 1; i <= a; i++) { 10 | fact *= i; 11 | } 12 | return fact; 13 | } 14 | 15 | static int factorial(int n) { 16 | // int fact = 1; 17 | if (n <= 1) { 18 | return 1; 19 | } 20 | return n * factorial(n - 1); 21 | } 22 | 23 | public static void main(String[] args) { 24 | int x = 9; 25 | // System.out.println(factorial(x)); 26 | System.out.println(factorial_interative(x)); 27 | } 28 | } 29 | 30 | 31 | /* 32 | * A function i Java can call itself, is recursion 33 | * 34 | * 35 | */ -------------------------------------------------------------------------------- /Day16/VariableArgument.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day16/VariableArgument.class -------------------------------------------------------------------------------- /Day16/VariableArgument.java: -------------------------------------------------------------------------------- 1 | public class VariableArgument { 2 | // static int foo(int a, int b) { 3 | // return a + b; 4 | // } 5 | 6 | // static int foo(int a, int b, int c) { 7 | // return a + b + c; 8 | // } 9 | 10 | // static int sumTheNumber(int... arr) { 11 | // // Available as int[] arr; 12 | // int result = 0; 13 | // for (int a : arr) { 14 | // result += a; 15 | // } 16 | // return result; 17 | // } 18 | // one argument must need to pass 19 | static int sumTheNumber(int x, int... arr) { 20 | // Available as int[] arr; 21 | int result = x; 22 | for (int a : arr) { 23 | result += a; 24 | } 25 | return result; 26 | } 27 | 28 | public static void main(String[] args) { 29 | // System.out.println("Welcome to this repository!"); 30 | // System.out.println(foo(2, 4)); 31 | int[] a = { 1, 2, 3 }; 32 | // System.out.println(sumTheNumber(1, 2, 4, 5, 6)); 33 | // System.out.println(sumTheNumber()); 34 | // System.out.println(sumTheNumber(a)); 35 | System.out.println(sumTheNumber(1)); 36 | } 37 | } 38 | 39 | /* 40 | * Pass argument 41 | * 42 | * 43 | */ -------------------------------------------------------------------------------- /Day17/CustomClass.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day17/CustomClass.class -------------------------------------------------------------------------------- /Day17/CustomClass.java: -------------------------------------------------------------------------------- 1 | class Employee { 2 | int id; 3 | String name; 4 | public void printDetails(int a){ 5 | System.out.println("Custom Code: " + a); 6 | System.out.println("ID: " + id); 7 | System.out.println("Name: " + name); 8 | } 9 | } 10 | 11 | public class CustomClass { 12 | 13 | public static void main(String[] args) { 14 | 15 | // intansiating new Employee Obj 16 | Employee sakib = new Employee(); 17 | Employee tobi = new Employee(); 18 | 19 | // setting attributes 20 | sakib.id = 12; 21 | sakib.name = "DevvSakib"; 22 | 23 | tobi.id = 13; 24 | tobi.name = "Tobiloba"; 25 | 26 | // printing attributes 27 | // sakib.printDetails(); 28 | // System.out.println(); 29 | // tobi.printDetails(); 30 | System.out.println(); 31 | sakib.printDetails(1); 32 | tobi.printDetails(2); 33 | 34 | } 35 | } 36 | /* 37 | * [One Java file one public class] 38 | * 39 | * We can write custom class 40 | * 41 | * 42 | * 43 | */ -------------------------------------------------------------------------------- /Day17/Employee.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day17/Employee.class -------------------------------------------------------------------------------- /Day17/OOP.java: -------------------------------------------------------------------------------- 1 | public class OOP { 2 | public static void main(String[] args) { 3 | 4 | } 5 | 6 | } 7 | /* 8 | * OOP - java 9 | * Object Oriented Programming tries to map code instruction with real world 10 | * making the code short and easier to understand. 11 | * 12 | * Why OOP? 13 | * 14 | * Solving a problem by creating objects is one of the most popular approaches 15 | * in programming. 16 | * 17 | * DRY - Do not Repeat Your-self 18 | * 19 | * Class 20 | * Class is a blueprint of an objects 21 | * 22 | * Object 23 | * Class instantiation 24 | * 25 | * OOPs Terminology 26 | * 1. Abstraction - Hiding internal details [only essential info show] 27 | * 28 | * 2. Excapsulation - The act of putting various components together. In java encapsulation means that the sensitive data can be hidden from the usres. 29 | * 30 | * 3. Inheritance - The act of deriving new things form existing things. 31 | * 32 | * 4. Polymorphism - One entity many forms. 33 | * 34 | * 35 | */ -------------------------------------------------------------------------------- /Day17/Practice.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day17/Practice.class -------------------------------------------------------------------------------- /Day17/Practice.java: -------------------------------------------------------------------------------- 1 | import javax.swing.text.html.HTMLDocument.RunElement; 2 | 3 | public class Practice { 4 | 5 | // Practice 1 6 | static void multiplication(int n) { 7 | for (int i = 1; i <= 10; i++) { 8 | System.out.format("%d x %d = %d \n", n, i, n * i); 9 | } 10 | } 11 | 12 | // Practice 2 13 | static void pattern(int a) { 14 | for (int i = 0; i < a; i++) { 15 | for (int j = 0; j < i + 1; j++) { 16 | System.out.print("⭐"); 17 | } 18 | System.out.println(); 19 | } 20 | // Practice 4 21 | for (int i = a; i > 0; i--) { 22 | for (int j = i; j > 0 + 1; j--) { 23 | System.out.print("⭐"); 24 | } 25 | System.out.println(); 26 | } 27 | } 28 | 29 | // Practice 3 30 | static int sumRecursive(int a) { 31 | if (a == 1) { 32 | return 1; 33 | } 34 | return a + sumRecursive(a - 1); 35 | } 36 | 37 | // Practice 5 38 | static int fibn(int a) { 39 | if (a == 1) { 40 | return 1; 41 | } 42 | if (a == 0) { 43 | return 0; 44 | } 45 | return fibn(a - 1) + fibn(a - 2); 46 | 47 | } 48 | 49 | static void patternRec(int a) { 50 | if (a > 0) { 51 | patternRec(a - 1); 52 | for (int j = 0; j < a; j++) { 53 | System.out.print("*"); 54 | } 55 | System.out.println(); 56 | } 57 | } 58 | 59 | public static void main(String[] args) { 60 | // multiplication(5); 61 | 62 | // pattern(5); 63 | 64 | // int x = sumRecursive(12); 65 | // System.out.println(x); 66 | 67 | // int fib = fibn(7); 68 | // System.out.println(fib); 69 | 70 | patternRec(5); 71 | 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /Day18/AccessModGetSet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day18/AccessModGetSet.class -------------------------------------------------------------------------------- /Day18/AccessModGetSet.java: -------------------------------------------------------------------------------- 1 | class myEmployee { 2 | private int id; 3 | private String name; 4 | 5 | public void setName(String n){ 6 | name = n; 7 | } 8 | public void setId(int x){ 9 | id = x; 10 | } 11 | public String getName(){ 12 | return name; 13 | } 14 | public int getId(){ 15 | return id; 16 | } 17 | } 18 | 19 | public class AccessModGetSet { 20 | public static void main(String[] args) { 21 | myEmployee rup = new myEmployee(); 22 | 23 | rup.setName("Rup"); 24 | System.out.println(rup.getName()); 25 | } 26 | 27 | 28 | } 29 | 30 | /* 31 | * Access Modifiers 32 | * ---------------- 33 | * Specifier where a property/method is accessible . 34 | * 4type of access modifiers: 35 | * 36 | * 1. Private 37 | * 2.Default 38 | * 3.Protected 39 | * 4.Public 40 | * 41 | * getters and Setters 42 | * ------------------ 43 | * Getter --> Return the value [Access] 44 | * Setter --> Set/update the value [modifer] 45 | * 46 | * 47 | * 48 | * 49 | */ -------------------------------------------------------------------------------- /Day18/Devv.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day18/Devv.class -------------------------------------------------------------------------------- /Day18/Employee.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day18/Employee.class -------------------------------------------------------------------------------- /Day18/Practice.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day18/Practice.class -------------------------------------------------------------------------------- /Day18/Practice.java: -------------------------------------------------------------------------------- 1 | class Employee { 2 | int salary; 3 | String name; 4 | 5 | public int getSalary() { 6 | return salary; 7 | } 8 | 9 | public String getName() { 10 | return name; 11 | } 12 | 13 | public void setName(String n) { 14 | name = n; 15 | } 16 | } 17 | 18 | class cellPhone { 19 | public void ring() { 20 | System.out.println("Ringing..."); 21 | } 22 | 23 | public void vibrate() { 24 | System.out.println("Virbating..."); 25 | } 26 | 27 | public void callFriend(String name) { 28 | System.out.println("Calling " + name + "..."); 29 | } 30 | } 31 | 32 | class Square { 33 | int side; 34 | 35 | public int area() { 36 | return side * side; 37 | } 38 | 39 | public int perimeter() { 40 | return 4 * side; 41 | } 42 | } 43 | 44 | class Devv{ 45 | public void hit(){ 46 | System.out.println("Hit... -1"); 47 | } 48 | public void fire(){ 49 | System.out.println("Fire... -4"); 50 | } 51 | public void run(){ 52 | System.out.println("Run..."); 53 | } 54 | 55 | } 56 | 57 | 58 | public class Practice { 59 | public static void main(String[] args) { 60 | // Practice 1 61 | // Employee sakib = new Employee(); 62 | // sakib.setName("DevvSakib"); 63 | // System.out.println(sakib.getName()); 64 | 65 | // Practice 2 66 | // cellPhone samsung = new cellPhone(); 67 | // samsung.callFriend("Tobi"); 68 | // samsung.ring(); 69 | // samsung.vibrate(); 70 | 71 | // Practice 3 72 | // Square sq = new Square(); 73 | // sq.side = 5; 74 | // System.out.println(sq.area()); 75 | // System.out.println(sq.perimeter()); 76 | 77 | // Practice 4 78 | Devv ds = new Devv(); 79 | ds.fire(); 80 | ds.hit(); 81 | ds.run(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Day18/Square.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day18/Square.class -------------------------------------------------------------------------------- /Day18/cellPhone.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day18/cellPhone.class -------------------------------------------------------------------------------- /Day18/myEmployee.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day18/myEmployee.class -------------------------------------------------------------------------------- /Day19/Constructors.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day19/Constructors.class -------------------------------------------------------------------------------- /Day19/Constructors.java: -------------------------------------------------------------------------------- 1 | class myEmployee { 2 | private int id; 3 | private String name; 4 | 5 | // Constructors 6 | public myEmployee(int myid, String myname) { 7 | id = myid; 8 | name = myname; 9 | } 10 | 11 | // Constructor overload 12 | public myEmployee() { 13 | id = 1; 14 | name = "Demo"; 15 | } 16 | 17 | public void setName(String n) { 18 | name = n; 19 | } 20 | 21 | public void setId(int x) { 22 | id = x; 23 | } 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public int getId() { 30 | return id; 31 | } 32 | } 33 | 34 | public class Constructors { 35 | 36 | public static void main(String[] args) { 37 | myEmployee ds = new myEmployee(); 38 | System.out.println(ds.getId()); 39 | System.out.println(ds.getName()); 40 | 41 | } 42 | } 43 | 44 | /* 45 | * Contructore name should be same as class name. 46 | * 47 | * 48 | */ -------------------------------------------------------------------------------- /Day19/RockPprscr.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day19/RockPprscr.class -------------------------------------------------------------------------------- /Day19/RockPprscr.java: -------------------------------------------------------------------------------- 1 | import java.util.Random; 2 | import java.util.Scanner; 3 | 4 | public class RockPprscr { 5 | public static void main(String[] args) { 6 | Scanner sc = new Scanner(System.in); 7 | System.out.println("Rock 0"); 8 | System.out.println("Paper 1"); 9 | System.out.println("Scissor 2"); 10 | System.out.print("Enter your number: "); 11 | int userInpt = sc.nextInt(); 12 | 13 | Random rand = new Random(); 14 | int comptInput = rand.nextInt(3); 15 | System.out.println(comptInput); 16 | 17 | if (userInpt == comptInput) { 18 | System.out.println("Draw"); 19 | } else if (userInpt == 0 && comptInput == 2 || userInpt == 1 && comptInput == 0 20 | || userInpt == 2 && comptInput == 1) { 21 | System.out.println("You won!"); 22 | } else { 23 | System.out.println("Computer won!"); 24 | } 25 | if (comptInput == 0) { 26 | System.out.println("Computer: Rock"); 27 | } else if (comptInput == 1) { 28 | System.out.println("Computer: Paper"); 29 | }else{ 30 | System.out.println("Computer: Scissor"); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Day19/myEmployee.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day19/myEmployee.class -------------------------------------------------------------------------------- /Day2/Literal.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day2/Literal.class -------------------------------------------------------------------------------- /Day2/Literal.java: -------------------------------------------------------------------------------- 1 | public class Literal { 2 | public static void main(String[] args) { 3 | int number = 12; 4 | float flt = 12.4f; // f or f 5 | double dbl = 122.434d; // d or D 6 | String str = "Hello, duble quote"; 7 | char str2 = 'H'; // only one character 8 | byte age = 90; // range -128 to 127 9 | long lng = 343243432423L; // add L or l for long data type 10 | boolean bl = false; // true false 11 | System.out.println(bl); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Day2/UserInput.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day2/UserInput.class -------------------------------------------------------------------------------- /Day2/UserInput.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | class UserInput { 3 | public static void main(String[] args) { 4 | System.out.println("Get input from users."); 5 | Scanner getInp = new Scanner(System.in); 6 | System.out.println("Enter a integer 1:"); 7 | int a = getInp.nextInt(); 8 | System.out.println("Enter a integer 2:"); 9 | int b = getInp.nextInt(); 10 | System.out.println(a + b); 11 | 12 | } 13 | } 14 | // in order to read data from the keyboard, java has a scanner class. Scanner 15 | // class has a lot of methods to read the data fromthe keyboard. 16 | // Scanner name = new Scanner(System.in) 17 | // System.in -> read from keyboard 18 | // 19 | // int a = name.nextInt() -> nextIn() read from keybaord integer -------------------------------------------------------------------------------- /Day2/tempCodeRunnerFile.java: -------------------------------------------------------------------------------- 1 | * -------------------------------------------------------------------------------- /Day20/Base.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day20/Base.class -------------------------------------------------------------------------------- /Day20/Cylinder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day20/Cylinder.class -------------------------------------------------------------------------------- /Day20/Derived.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day20/Derived.class -------------------------------------------------------------------------------- /Day20/Inheritance.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day20/Inheritance.class -------------------------------------------------------------------------------- /Day20/Inheritance.java: -------------------------------------------------------------------------------- 1 | class Base { 2 | int x; 3 | 4 | public void setX(int x) { 5 | this.x = x; 6 | } 7 | 8 | public int getX() { 9 | return x; 10 | } 11 | 12 | public void printHim() { 13 | System.out.println("Hey I'm Him"); 14 | } 15 | } 16 | 17 | /* 18 | * Inheritance 19 | * Derived class name; 20 | */ 21 | 22 | class Derived extends Base { 23 | int y; 24 | 25 | public void setY(int y) { 26 | this.y = y; 27 | } 28 | 29 | public int getY() { 30 | return y; 31 | } 32 | } 33 | 34 | public class Inheritance { 35 | public static void main(String[] args) { 36 | Base b = new Base(); 37 | b.setX(3); 38 | int t = b.getX(); 39 | System.out.println(t); 40 | 41 | Derived c = new Derived(); 42 | c.setX(4); 43 | int p = c.getX(); 44 | System.out.println(p); 45 | } 46 | } 47 | /* 48 | * Inheritance is used to borrow properties from existing class. 49 | * 50 | * Superclass Base -> Subclass Derived 51 | * 52 | * Browser -> Chrome Browser with many feature. 53 | * 54 | * When a class inherits from a superclass, itinherits parts of superclass method and fields Java doesn't support multiple inheritance. 55 | * Two class cannot be super classes for a subclass. 56 | */ -------------------------------------------------------------------------------- /Day20/Practice.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day20/Practice.class -------------------------------------------------------------------------------- /Day20/Practice.java: -------------------------------------------------------------------------------- 1 | import org.w3c.dom.css.Rect; 2 | 3 | class Cylinder { 4 | // Practice 01 5 | private int radius; 6 | private int height; 7 | 8 | // Practice 03 9 | public Cylinder(int height, int radius) { 10 | this.height = height; 11 | this.radius = radius; 12 | } 13 | 14 | public void setHeight(int height) { 15 | this.height = height; 16 | } 17 | 18 | public void setRadius(int radius) { 19 | this.radius = radius; 20 | } 21 | 22 | public int getHeight() { 23 | return height; 24 | } 25 | 26 | public int getRadius() { 27 | return radius; 28 | } 29 | 30 | // Practice 02 31 | public double surfaceArea() { 32 | return 2 * Math.PI * radius * radius + 2 * Math.PI * radius * height; 33 | } 34 | 35 | public double volume() { 36 | return Math.PI * radius * radius * height; 37 | } 38 | 39 | } 40 | 41 | // Practice 04 42 | class Rectangle { 43 | private int length; 44 | private int breadth; 45 | 46 | public Rectangle(int length, int breadth) { 47 | this.length = length; 48 | this.breadth = breadth; 49 | } 50 | 51 | public int getLength() { 52 | return length; 53 | } 54 | 55 | public int getBreadth() { 56 | return breadth; 57 | } 58 | 59 | 60 | } 61 | 62 | public class Practice { 63 | public static void main(String[] args) { 64 | // Practice 01 65 | // Cylinder myCl = new Cylinder(); 66 | // myCl.setHeight(12); 67 | // System.out.println(myCl.getHeight()); 68 | // myCl.setRadius(9); 69 | // System.out.println(myCl.getRadius()); 70 | 71 | // Practice 02 72 | // System.out.println(myCl.surfaceArea()); 73 | // System.out.println(myCl.volume()); 74 | 75 | // Practice 03 76 | // Cylinder myCl = new Cylinder(12, 9); 77 | // System.out.println(myCl.volume()); 78 | 79 | // Practice 04 80 | Rectangle myRec = new Rectangle(12, 9); 81 | System.out.println(myRec.getLength()); 82 | System.out.println(myRec.getBreadth()); 83 | 84 | 85 | 86 | 87 | } 88 | } -------------------------------------------------------------------------------- /Day20/Rectangle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day20/Rectangle.class -------------------------------------------------------------------------------- /Day21/Base1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day21/Base1.class -------------------------------------------------------------------------------- /Day21/ChildOfDerived.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day21/ChildOfDerived.class -------------------------------------------------------------------------------- /Day21/ConsInInheritance.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day21/ConsInInheritance.class -------------------------------------------------------------------------------- /Day21/ConsInInheritance.java: -------------------------------------------------------------------------------- 1 | class Base1 { 2 | // constructor 3 | Base1() { 4 | System.out.println("Im a Base constructor"); 5 | } 6 | 7 | Base1(int a) { 8 | System.out.println("Im a Base Arg constructor " + a); 9 | } 10 | 11 | } 12 | 13 | class Derived1 extends Base1 { 14 | // constructor 15 | Derived1() { 16 | super(0); 17 | System.out.println("Im a constructor | Derived"); 18 | } 19 | 20 | Derived1(int a, int b) { 21 | super(1); 22 | System.out.println("Im a constructor | Derived arg " + a + " " + b); 23 | } 24 | 25 | } 26 | 27 | class ChildOfDerived extends Derived1 { 28 | ChildOfDerived() { 29 | System.out.println("I'm a child of Derive"); 30 | } 31 | 32 | ChildOfDerived(int x, int y) { 33 | super(x, y); 34 | System.out.println("I'm a child of Derive with arg " + x + " " + y); 35 | } 36 | } 37 | 38 | public class ConsInInheritance { 39 | public static void main(String[] args) { 40 | // Base1 b = new Base1(1); 41 | // Derived1 b = new Derived1(1); 42 | ChildOfDerived d = new ChildOfDerived(10,12); 43 | 44 | } 45 | } 46 | /* 47 | * Constructor in Inheritance 48 | * -------------------------- 49 | * When a Derived Class is extened from the Base class, the constructor of the 50 | * base class is executed first followed by the constructor of the derived 51 | * class. 52 | * 53 | */ -------------------------------------------------------------------------------- /Day21/Derived.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day21/Derived.class -------------------------------------------------------------------------------- /Day21/Derived1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day21/Derived1.class -------------------------------------------------------------------------------- /Day21/DoClass.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day21/DoClass.class -------------------------------------------------------------------------------- /Day21/EkClass.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day21/EkClass.class -------------------------------------------------------------------------------- /Day21/ThisSuper.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day21/ThisSuper.class -------------------------------------------------------------------------------- /Day21/ThisSuper.java: -------------------------------------------------------------------------------- 1 | class EkClass { 2 | int a; 3 | 4 | public int getA() { 5 | return a; 6 | } 7 | 8 | EkClass() { 9 | 10 | } 11 | 12 | EkClass(int x) { 13 | this.a = x; 14 | System.out.println("This is base cons with para " + x); 15 | } 16 | 17 | public int returnnone() { 18 | return 1; 19 | } 20 | } 21 | 22 | class DoClass extends EkClass { 23 | DoClass(int a) { 24 | super(a); 25 | System.out.println("I'm a doclass cons with para " + a); 26 | } 27 | } 28 | 29 | public class ThisSuper { 30 | public static void main(String[] args) { 31 | EkClass ec = new EkClass(10); 32 | DoClass dc = new DoClass(11); 33 | System.out.println(ec.getA()); 34 | } 35 | } 36 | 37 | /* 38 | * this-> 39 | * -----> 40 | * this is a way for us to reference an object of the class which is being 41 | * created or referenced. 42 | * 43 | * refer current class 44 | * 45 | * super-> 46 | * ------> 47 | * When there are multiple Constructors in the parent class, the constructor 48 | * without any parameters is called from the child class. 49 | * If we want to call the constructor with parameter from the parent calss, we 50 | * can use super keyword. 51 | * 52 | * 53 | * 54 | */ -------------------------------------------------------------------------------- /Day22/A.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day22/A.class -------------------------------------------------------------------------------- /Day22/B.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day22/B.class -------------------------------------------------------------------------------- /Day22/DynMethodDispatch.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day22/DynMethodDispatch.class -------------------------------------------------------------------------------- /Day22/DynMethodDispatch.java: -------------------------------------------------------------------------------- 1 | class One { 2 | public void greet() { 3 | System.out.println("Welcome to Main class One"); 4 | } 5 | 6 | public void name() { 7 | System.out.println("Im Main class One"); 8 | } 9 | } 10 | 11 | class Two extends One { 12 | public void wlcm() { 13 | System.out.println("Welcome to Derived class Two"); 14 | } 15 | 16 | public void name() { 17 | System.out.println("Im Derived class Two"); 18 | } 19 | } 20 | 21 | public class DynMethodDispatch { 22 | public static void main(String[] args) { 23 | // One obj = new One(); 24 | // Two obj2 = new Two(); 25 | // obj.name(); 26 | // obj2.name(); 27 | 28 | One obj = new Two(); 29 | obj.greet(); 30 | obj.name(); 31 | // obj.wlcm(); 32 | /* 33 | * Super class reference can be sub class object 34 | * sub class reference can't be super class object 35 | */ 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Day22/MethodOverriding.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day22/MethodOverriding.class -------------------------------------------------------------------------------- /Day22/MethodOverriding.java: -------------------------------------------------------------------------------- 1 | class A { 2 | public int a; 3 | 4 | public int sakib() { 5 | return 4; 6 | } 7 | 8 | // overriding -> 9 | // public void meth2(int a) { 10 | 11 | // not overriding -> 12 | public void meth2() { 13 | System.out.println("Method 2 from class A"); 14 | } 15 | } 16 | 17 | class B extends A { 18 | @Override 19 | public void meth2() { 20 | System.out.println("Method 2 from class B"); 21 | } 22 | 23 | public void meth3() { 24 | System.out.println("Method 3 from class B"); 25 | } 26 | } 27 | 28 | public class MethodOverriding { 29 | public static void main(String[] args) { 30 | A a = new A(); 31 | a.meth2(); 32 | 33 | B b = new B(); 34 | b.meth2(); 35 | 36 | } 37 | } 38 | 39 | /* 40 | * If the child class implements the same method present in the parent class 41 | * again, it is known as method overriding. 42 | * 43 | */ -------------------------------------------------------------------------------- /Day22/One.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day22/One.class -------------------------------------------------------------------------------- /Day22/Two.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day22/Two.class -------------------------------------------------------------------------------- /Day23/Game.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day23/Game.class -------------------------------------------------------------------------------- /Day23/GuesTheNum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day23/GuesTheNum.class -------------------------------------------------------------------------------- /Day23/GuesTheNum.java: -------------------------------------------------------------------------------- 1 | import java.util.Random; 2 | import java.util.Scanner;; 3 | 4 | class Game { 5 | public int num; 6 | public int inputNum; 7 | public int noOfGuesses = 0; 8 | 9 | public int getNoGuess() { 10 | return noOfGuesses; 11 | } 12 | 13 | public void setNoGuess(int noOfGuesses) { 14 | this.noOfGuesses = noOfGuesses; 15 | } 16 | 17 | Game() { 18 | Random rand = new Random(); 19 | this.num = rand.nextInt(100); 20 | } 21 | 22 | void takeUserInput() { 23 | System.out.println("Guess The Number"); 24 | Scanner sc = new Scanner(System.in); 25 | inputNum = sc.nextInt(); 26 | } 27 | 28 | boolean isCorrectNumber() { 29 | noOfGuesses++; 30 | if (inputNum == num) { 31 | System.out.println("You Win! after trying: " + noOfGuesses); 32 | return true; 33 | } else if (inputNum > num) { 34 | System.out.println("Too High..."); 35 | } else if (inputNum < num) { 36 | System.out.println("Too Low..."); 37 | } 38 | return false; 39 | 40 | } 41 | 42 | } 43 | 44 | public class GuesTheNum { 45 | public static void main(String[] args) { 46 | Game g = new Game(); 47 | g.takeUserInput(); 48 | boolean b = false; 49 | while (!b) { 50 | g.isCorrectNumber(); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Day24/AbstractClassMethod.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day24/AbstractClassMethod.class -------------------------------------------------------------------------------- /Day24/AbstractClassMethod.java: -------------------------------------------------------------------------------- 1 | abstract class Parent { 2 | public Parent() { 3 | System.out.println("Base2 Cons"); 4 | } 5 | 6 | public void sayHello() { 7 | System.out.println("Hello"); 8 | } 9 | 10 | abstract public void greet(); 11 | abstract public void greet2(); 12 | } 13 | 14 | class Child extends Parent { 15 | @Override 16 | public void greet() { 17 | System.out.println("Good Morning form Child"); 18 | } 19 | @Override 20 | public void greet2() { 21 | System.out.println("Good Morning form Child"); 22 | } 23 | } 24 | abstract class Child2 extends Parent { 25 | public void th() { 26 | System.out.println("I'm Good"); 27 | } 28 | } 29 | 30 | public class AbstractClassMethod { 31 | public static void main(String[] args) { 32 | // Parent p = new Parent(); 33 | Child c = new Child(); 34 | // Child2 c2 = new Child2(); 35 | 36 | } 37 | } 38 | /* 39 | * Abstract Class 40 | * -------------- 41 | * If a class includes abstract methods, then the class itself must be declared 42 | * abstract. 43 | * 44 | * public abstract class Phone{ 45 | * abstract void off(); 46 | * } 47 | * 48 | * 49 | * Abstract Method 50 | * --------------- 51 | * A method that is declared without an implementation 52 | * 53 | * abstract void moveTo(int x, int y) 54 | * 55 | */ -------------------------------------------------------------------------------- /Day24/Child.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day24/Child.class -------------------------------------------------------------------------------- /Day24/Child2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day24/Child2.class -------------------------------------------------------------------------------- /Day24/Parent.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day24/Parent.class -------------------------------------------------------------------------------- /Day25/Bicycle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day25/Bicycle.class -------------------------------------------------------------------------------- /Day25/ElectricBicycle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day25/ElectricBicycle.class -------------------------------------------------------------------------------- /Day25/HornBicycle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day25/HornBicycle.class -------------------------------------------------------------------------------- /Day25/Interfaces.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day25/Interfaces.class -------------------------------------------------------------------------------- /Day25/Interfaces.java: -------------------------------------------------------------------------------- 1 | /** 2 | * InnerInterfaces 3 | **/ 4 | interface Bicycle { 5 | int a = 50; 6 | 7 | // final int a = 50; //final is not require to write, its default 8 | void applyBrack(int decSpeed); 9 | 10 | void speedUp(int incSpeed); 11 | } 12 | 13 | interface HornBicycle { 14 | void blowHornK3g(); 15 | 16 | void blowHornMnh(); 17 | } 18 | 19 | class ElectricBicycle implements Bicycle, HornBicycle { 20 | int speed = 10; 21 | 22 | void pressHorn() { 23 | System.out.println("Pep Pep..."); 24 | } 25 | 26 | public void applyBrack(int decSpeed) { 27 | speed = speed - decSpeed; 28 | System.out.println("Brake pressed..."); 29 | }; 30 | 31 | public void speedUp(int incSpeed) { 32 | speed += incSpeed; 33 | System.out.println("Speeding up cycle..."); 34 | } 35 | public void blowHornK3g(){ 36 | System.out.println("Horn k3G from another interface"); 37 | } 38 | public void blowHornMnh(){ 39 | System.out.println("Horn Mnh from another interface"); 40 | } 41 | 42 | } 43 | 44 | public class Interfaces { 45 | public static void main(String[] args) { 46 | ElectricBicycle bc = new ElectricBicycle(); 47 | bc.applyBrack(10); 48 | bc.pressHorn(); 49 | bc.speedUp(1); 50 | 51 | // cannot modify the properties in Interface, they are final 52 | bc.blowHornK3g(); 53 | bc.blowHornMnh(); 54 | } 55 | } 56 | /* 57 | * INTERFACES 58 | * ---------- 59 | * In English, a point where two system meet and interact. 60 | * 61 | * TV <----BUTTON----> HUMAN 62 | * Mouse, Keybaord, Powerswtich... 63 | * 64 | * In java interface is a group of related method with empty bodies 65 | * 66 | * 67 | * 68 | */ -------------------------------------------------------------------------------- /Day26/Camera.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day26/Camera.class -------------------------------------------------------------------------------- /Day26/CellPhone.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day26/CellPhone.class -------------------------------------------------------------------------------- /Day26/MoreInterfaces.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day26/MoreInterfaces.class -------------------------------------------------------------------------------- /Day26/MoreInterfaces.java: -------------------------------------------------------------------------------- 1 | interface Camera { 2 | void takeSnap(); 3 | 4 | void recordVideo(); 5 | 6 | private void greet() { 7 | System.out.println("Hello Samsung"); 8 | } // we cant use private method directly 9 | 10 | default void record4kVideo() { 11 | greet(); 12 | System.out.println("Record 4k Video"); 13 | } 14 | } 15 | 16 | interface Wifi { 17 | String[] getNetwork(); 18 | 19 | void connectToNetwork(String network); 20 | 21 | } 22 | 23 | class CellPhone { 24 | void callNumber(int phoneNumber) { 25 | System.out.println("Calling " + phoneNumber); 26 | } 27 | 28 | void pickCall() { 29 | System.out.println("Connecting "); 30 | } 31 | 32 | } 33 | 34 | class SmartPhone extends CellPhone implements Wifi, Camera { 35 | public void takeSnap() { 36 | System.out.println("Clicking..."); 37 | } 38 | 39 | public void recordVideo() { 40 | 41 | System.out.println("Video recording..."); 42 | } 43 | 44 | public String[] getNetwork() { 45 | System.out.println("Getting Network..."); 46 | String[] networkList = { "DevvSakib", "Chang Wook", "Eun Tak", "Park Bong" }; 47 | return networkList; 48 | } 49 | 50 | // public void record4kVideo() { 51 | // System.out.println("record 4k updated"); 52 | // // deafult method will not work 53 | // } 54 | 55 | public void connectToNetwork(String network) { 56 | System.out.println("Connecting network... " + network); 57 | } 58 | } 59 | 60 | public class MoreInterfaces { 61 | public static void main(String[] args) { 62 | SmartPhone ms = new SmartPhone(); 63 | ms.record4kVideo(); 64 | // ms.greet(); // we cant use private method directly 65 | String[] ar = ms.getNetwork(); 66 | for (String str : ar) { 67 | System.out.println(str); 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /Day26/SmartPhone.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day26/SmartPhone.class -------------------------------------------------------------------------------- /Day26/Wifi.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day26/Wifi.class -------------------------------------------------------------------------------- /Day27/InheritanceInterfaces.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day27/InheritanceInterfaces.class -------------------------------------------------------------------------------- /Day27/InheritanceInterfaces.java: -------------------------------------------------------------------------------- 1 | interface sampleInterface { 2 | void meth1(); 3 | void meth2(); 4 | } 5 | interface childSample extends sampleInterface{ 6 | void meth1(); 7 | void meth2(); 8 | } 9 | class MySample implements childSample{ 10 | public void meth1(){ 11 | System.out.println("meth1"); 12 | } 13 | public void meth2(){ 14 | System.out.println("meth2"); 15 | } 16 | public void meth3(){ 17 | System.out.println("meth3"); 18 | } 19 | public void meth4(){ 20 | System.out.println("meth4"); 21 | } 22 | } 23 | 24 | 25 | public class InheritanceInterfaces { 26 | public static void main(String[] args) { 27 | MySample ms = new MySample(); 28 | ms.meth2(); 29 | ms.meth3(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Day27/MySample.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day27/MySample.class -------------------------------------------------------------------------------- /Day27/Polymorphism/Camera.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day27/Polymorphism/Camera.class -------------------------------------------------------------------------------- /Day27/Polymorphism/CellPhone.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day27/Polymorphism/CellPhone.class -------------------------------------------------------------------------------- /Day27/Polymorphism/Polymorphism.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day27/Polymorphism/Polymorphism.class -------------------------------------------------------------------------------- /Day27/Polymorphism/Polymorphism.java: -------------------------------------------------------------------------------- 1 | interface Camera { 2 | void takeSnap(); 3 | 4 | void recordVideo(); 5 | 6 | private void greet() { 7 | System.out.println("Hello Samsung"); 8 | } // we cant use private method directly 9 | 10 | default void record4kVideo() { 11 | greet(); 12 | System.out.println("Record 4k Video"); 13 | } 14 | } 15 | 16 | interface Wifi { 17 | String[] getNetwork(); 18 | 19 | void connectToNetwork(String network); 20 | 21 | } 22 | 23 | class CellPhone { 24 | void callNumber(int phoneNumber) { 25 | System.out.println("Calling " + phoneNumber); 26 | } 27 | 28 | void pickCall() { 29 | System.out.println("Connecting "); 30 | } 31 | 32 | } 33 | 34 | class SmartPhone extends CellPhone implements Wifi, Camera { 35 | public void takeSnap() { 36 | System.out.println("Clicking..."); 37 | } 38 | 39 | public void recordVideo() { 40 | 41 | System.out.println("Video recording..."); 42 | } 43 | 44 | public String[] getNetwork() { 45 | System.out.println("Getting Network..."); 46 | String[] networkList = { "DevvSakib", "Chang Wook", "Eun Tak", "Park Bong" }; 47 | return networkList; 48 | } 49 | 50 | public void connectToNetwork(String network) { 51 | System.out.println("Connecting network... " + network); 52 | } 53 | } 54 | 55 | public class Polymorphism { 56 | public static void main(String[] args) { 57 | Camera cam1 = new SmartPhone(); // this is a smartphone, only use this only for camera 58 | // cam1.getNetwork(); // not allowed, use only camera 59 | cam1.record4kVideo(); 60 | 61 | Wifi wf = new SmartPhone(); // this is a smartphone, only use this only for wifi 62 | // wf.record4kVideo(); // not allowed 63 | wf.getNetwork(); // allowed 64 | 65 | SmartPhone sp = new SmartPhone(); // Now use everything. 66 | sp.getNetwork(); 67 | sp.record4kVideo(); 68 | sp.takeSnap(); 69 | 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Day27/Polymorphism/SmartPhone.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day27/Polymorphism/SmartPhone.class -------------------------------------------------------------------------------- /Day27/Polymorphism/Wifi.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day27/Polymorphism/Wifi.class -------------------------------------------------------------------------------- /Day27/childSample.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day27/childSample.class -------------------------------------------------------------------------------- /Day27/sampleInterface.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day27/sampleInterface.class -------------------------------------------------------------------------------- /Day28/BasicAnimal.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day28/BasicAnimal.class -------------------------------------------------------------------------------- /Day28/FountainPen.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day28/FountainPen.class -------------------------------------------------------------------------------- /Day28/Human.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day28/Human.class -------------------------------------------------------------------------------- /Day28/Monkey.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day28/Monkey.class -------------------------------------------------------------------------------- /Day28/Pen.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day28/Pen.class -------------------------------------------------------------------------------- /Day28/Practice.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day28/Practice.class -------------------------------------------------------------------------------- /Day28/Practice.java: -------------------------------------------------------------------------------- 1 | // Practice 1: create an abastract class with 2 method. 2 | abstract class Pen { 3 | abstract void write(); 4 | 5 | abstract void refill(); 6 | } 7 | 8 | class FountainPen extends Pen { 9 | void write() { 10 | System.out.println("Writing.."); 11 | } 12 | 13 | void refill() { 14 | System.out.println("Refilling..."); 15 | } 16 | 17 | void changeBall() { 18 | System.out.println("Changing Ball..."); 19 | } 20 | 21 | } 22 | 23 | // Practice 2: write a class named Monkey with two method. Create a class Human 24 | // which inherits this Monkey class and implements BasicAnimal interface with 25 | // eat() sleep() methods 26 | class Monkey { 27 | void Jump() { 28 | System.out.println("jump"); 29 | } 30 | 31 | void Bite() { 32 | System.out.println("Bite"); 33 | } 34 | } 35 | 36 | interface BasicAnimal { 37 | void Eat(); 38 | 39 | void Sleep(); 40 | } 41 | 42 | class Human extends Monkey implements BasicAnimal { 43 | void Speak() { 44 | System.out.println("Speaking..."); 45 | } 46 | 47 | @Override 48 | public void Eat() { 49 | System.out.println("Eating..."); 50 | } 51 | 52 | @Override 53 | public void Sleep() { 54 | System.out.println("Sleeping..."); 55 | 56 | } 57 | 58 | } 59 | 60 | // Practice 3: 61 | 62 | public class Practice { 63 | public static void main(String[] args) { 64 | // p1 65 | FountainPen pen = new FountainPen(); 66 | // pen.changeBall(); 67 | 68 | // p2 69 | Human s1 = new Human(); 70 | // s1.Sleep(); 71 | // s1.Jump(); 72 | // s1.Eat(); 73 | 74 | // p3 75 | Monkey m1 = new Human(); 76 | // m1.Jump(); 77 | // m1.Bite(); 78 | // m1.Sleep(); // cannt use sleep method, only monkey class included method are allowed to use. 79 | 80 | BasicAnimal b1 = new Human(); 81 | b1.Sleep(); 82 | b1.Eat(); 83 | 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Day29/CompInter/CompInter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day29/CompInter/CompInter.class -------------------------------------------------------------------------------- /Day29/CompInter/CompInter.java: -------------------------------------------------------------------------------- 1 | public class CompInter { 2 | public static void main(String[] args) { 3 | System.out.println(123); 4 | } 5 | } 6 | 7 | /* 8 | * Hybrid Language Java 9 | * Compiled and Interpreter 10 | * Java File ------> Java Class --> Use 11 | * a.java -- javac - Byte code --> 12 | * -------- compiled------------ Interpreter 13 | * 14 | * 15 | * JVM --> Interprete the byte code 16 | * Byte code can be use in any platform (max,win,linux) 17 | * Platform independent 18 | * 19 | * Javac test.java --> compiled 20 | * java test.class --> interpreted 21 | * 22 | * 23 | * Interpreter translate one statement at a time into machine code. 24 | * One statement at a time 25 | * Interpreter needed everytime 26 | * Partial execution error 27 | * Easy for programmers 28 | * 29 | * 30 | * Compiled scan whole program and turn into machine code. 31 | * Entire program at a time 32 | * Once compile 33 | * No execution for error 34 | * Not easy as interpreter 35 | * 36 | */ -------------------------------------------------------------------------------- /Day29/Package.java: -------------------------------------------------------------------------------- 1 | package common; 2 | // package common.anotherFolder; 3 | // package common.anotherFolder.anotherFolder; 4 | 5 | import common.Package2; 6 | 7 | public class Package { 8 | public static void main(String[] args) { 9 | System.out.println("Use package"); 10 | Package2 pk2 = new Package2(); 11 | 12 | } 13 | } 14 | 15 | /* 16 | * Package use to group related class. 17 | * javac -d . *.java 18 | * javac -d . Test.java 19 | * javac -d newFolder Test.java 20 | * 21 | */ 22 | -------------------------------------------------------------------------------- /Day29/Package1.java: -------------------------------------------------------------------------------- 1 | package common; 2 | 3 | public class Package1 { 4 | public static void main(String[] args) { 5 | System.out.println("Package1"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Day29/Package2.java: -------------------------------------------------------------------------------- 1 | package common; 2 | 3 | public class Package2 { 4 | public static void main(String[] args) { 5 | System.out.println("Package2"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Day29/common/Package.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day29/common/Package.class -------------------------------------------------------------------------------- /Day29/common/Package1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day29/common/Package1.class -------------------------------------------------------------------------------- /Day29/common/Package2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day29/common/Package2.class -------------------------------------------------------------------------------- /Day3/Practice.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class Practice { 4 | public static void main(String[] args){ 5 | // Excercise 1 -> sum of three 6 | // int a = 10; 7 | // int b = 20; 8 | // int c = 30; 9 | // int sum = a + b + c; 10 | // System.out.println(sum); 11 | 12 | // Excercise 2 -> average number 13 | // float eng = 55; 14 | // float math = 85; 15 | // float ict = 90; 16 | // float cgpa = (eng + math + ict) / 30; 17 | // System.out.println(cgpa); 18 | 19 | // Excercise 3 -> get user input 20 | // System.out.println("Your name:"); 21 | // Scanner sc = new Scanner(System.in); 22 | // String name = sc.next(); 23 | // System.out.println("Hello" + name); 24 | 25 | // Excercise 4 -> check if it's integer 26 | // System.out.println("Number:"); 27 | // Scanner sc = new Scanner(System.in); 28 | // System.out.println(sc.hasNextInt()); 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Day30/AccessModi.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day30/AccessModi.class -------------------------------------------------------------------------------- /Day30/AccessModi.java: -------------------------------------------------------------------------------- 1 | class C1 { 2 | public int x = 10; 3 | protected int y = 5; 4 | int z = 6; 5 | private int a = 90; 6 | 7 | public void method1() { 8 | System.out.println(x); 9 | // System.out.println(a); 10 | } 11 | } 12 | 13 | class C2 extends C1 { 14 | 15 | } 16 | 17 | public class AccessModi { 18 | public static void main(String[] args) { 19 | C1 c = new C1(); 20 | c.method1(); 21 | // System.out.println(c.a); // cant access due to private, access only in same 22 | // class. line-09 23 | } 24 | } 25 | /* 26 | * Determain whether other classes can use a particuler field or invoke a 27 | * particular method can be public, private, protected, or default 28 | * 29 | * |-------------------------------------------------------| 30 | * | Modifier -|- Class -|- Package -|- Subclass -|- World | 31 | * |-----------|---------|-----------|------------|--------| 32 | * | Public ---|--- Y ---|----- Y ---|----- Y ----|--- Y --| 33 | * | Private --|--- Y ---|----- N ---|----- N ----|--- N --| 34 | * | Protected |--- Y ---|----- Y ---|----- Y ----|--- N --| 35 | * | Default --|--- Y ---|----- Y ---|----- N ----|--- N --| 36 | * |-----------|---------|-----------|------------|--------| 37 | */ -------------------------------------------------------------------------------- /Day30/C1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day30/C1.class -------------------------------------------------------------------------------- /Day30/C2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day30/C2.class -------------------------------------------------------------------------------- /Day30/Practice/Practice.java: -------------------------------------------------------------------------------- 1 | package calc; 2 | 3 | class Calculator { 4 | public void calculator(int a, int b) { 5 | System.out.println("Sum of a + b " + (a + b)); 6 | } 7 | } 8 | 9 | class ScCalculator { 10 | public void calculator(int a, int b) { 11 | System.out.println("Sum of a + b " + Math.sin(a + b)); 12 | } 13 | } 14 | 15 | class HyCalculator { 16 | public void calculator(int a, int b) { 17 | System.out.println("Sum of a + b " + (a + b)); 18 | System.out.println("Sum of a + b " + Math.sin(a + b)); 19 | } 20 | } 21 | 22 | public class Practice { 23 | public static void main(String[] args) { 24 | System.out.println("Calculator"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Day30/Practice/Practice2.java: -------------------------------------------------------------------------------- 1 | package pack.pack1.pack2; 2 | 3 | class Calculator { 4 | public void calculator(int a, int b) { 5 | System.out.println("Sum of a + b " + (a + b)); 6 | } 7 | } 8 | 9 | class ScCalculator { 10 | public void calculator(int a, int b) { 11 | System.out.println("Sum of a + b " + Math.sin(a + b)); 12 | } 13 | } 14 | 15 | class HyCalculator { 16 | public void calculator(int a, int b) { 17 | System.out.println("Sum of a + b " + (a + b)); 18 | System.out.println("Sum of a + b " + Math.sin(a + b)); 19 | } 20 | } 21 | 22 | public class Practice2 { 23 | protected int proInt = 5; 24 | int defInt = 50; 25 | public static void main(String[] args) { 26 | System.out.println("Calculator"); 27 | } 28 | } -------------------------------------------------------------------------------- /Day30/Practice/Practice3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day30/Practice/Practice3.class -------------------------------------------------------------------------------- /Day30/Practice/Practice3.java: -------------------------------------------------------------------------------- 1 | import pack.pack1.pack2.Practice2; 2 | 3 | class c1 extends Practice2 { 4 | void prob2() { 5 | System.out.println(proInt); 6 | System.out.println(defInt); 7 | } 8 | } 9 | 10 | public class Practice3 { 11 | public static void main(String[] args) { 12 | c1 c = new c1(); 13 | } 14 | } -------------------------------------------------------------------------------- /Day30/Practice/c1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day30/Practice/c1.class -------------------------------------------------------------------------------- /Day30/Practice/calc/Calculator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day30/Practice/calc/Calculator.class -------------------------------------------------------------------------------- /Day30/Practice/calc/HyCalculator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day30/Practice/calc/HyCalculator.class -------------------------------------------------------------------------------- /Day30/Practice/calc/Practice.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day30/Practice/calc/Practice.class -------------------------------------------------------------------------------- /Day30/Practice/calc/ScCalculator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day30/Practice/calc/ScCalculator.class -------------------------------------------------------------------------------- /Day30/Practice/pack/pack1/pack2/Calculator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day30/Practice/pack/pack1/pack2/Calculator.class -------------------------------------------------------------------------------- /Day30/Practice/pack/pack1/pack2/HyCalculator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day30/Practice/pack/pack1/pack2/HyCalculator.class -------------------------------------------------------------------------------- /Day30/Practice/pack/pack1/pack2/Practice2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day30/Practice/pack/pack1/pack2/Practice2.class -------------------------------------------------------------------------------- /Day30/Practice/pack/pack1/pack2/ScCalculator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day30/Practice/pack/pack1/pack2/ScCalculator.class -------------------------------------------------------------------------------- /Day31/ExtendThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day31/ExtendThread.class -------------------------------------------------------------------------------- /Day31/ExtendThread.java: -------------------------------------------------------------------------------- 1 | class MyThread extends Thread { 2 | @Override 3 | public void run() { 4 | int i = 0; 5 | while (i < 1000) { 6 | System.out.println("Thread 1 Programme Runing.."); 7 | i++; 8 | } 9 | } 10 | } 11 | 12 | class MyThread2 extends Thread { 13 | @Override 14 | public void run() { 15 | int i = 0; 16 | while (i < 1000) { 17 | System.out.println("Thread 2 Programme Runing.."); 18 | i++; 19 | } 20 | } 21 | } 22 | public class ExtendThread { 23 | public static void main(String[] args) { 24 | MyThread mt = new MyThread(); 25 | MyThread2 mt2 = new MyThread2(); 26 | mt.start(); 27 | mt2.start(); 28 | } 29 | } -------------------------------------------------------------------------------- /Day31/MultiThreading.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day31/MultiThreading.class -------------------------------------------------------------------------------- /Day31/MultiThreading.java: -------------------------------------------------------------------------------- 1 | public class MultiThreading { 2 | public static void main(String[] args) { 3 | System.out.println("MultiThread "); 4 | } 5 | } 6 | /* 7 | * Multithreading 8 | * -------------- 9 | * Multiprocessing and multithreading both are used to achieve multitasking. 10 | * 11 | * 12 | * Flow 13 | * 14 | * No Threading-> 15 | * Main() -> func1() -> func2() -> End 16 | * 17 | * Threading-> 18 | * Main -> Func() ===| 19 | * ------------------|==> End 20 | * ------- Func2() ==| 21 | * 22 | * 23 | * Creating a Thread 24 | * There are two ways to create a thread. 25 | * i. extenda thread class 26 | * ii. implementing Runnable interfaces 27 | * 28 | * 29 | */ -------------------------------------------------------------------------------- /Day31/MyThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day31/MyThread.class -------------------------------------------------------------------------------- /Day31/MyThread2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day31/MyThread2.class -------------------------------------------------------------------------------- /Day31/RunnableThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day31/RunnableThread.class -------------------------------------------------------------------------------- /Day31/RunnableThread2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day31/RunnableThread2.class -------------------------------------------------------------------------------- /Day31/ThreadRunnable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day31/ThreadRunnable.class -------------------------------------------------------------------------------- /Day31/ThreadRunnable.java: -------------------------------------------------------------------------------- 1 | class RunnableThread implements Runnable { 2 | public void run() { 3 | System.out.println("Runnable thread 1 running"); 4 | } 5 | } 6 | 7 | class RunnableThread2 implements Runnable { 8 | public void run() { 9 | System.out.println("Runnable thread 2 running"); 10 | } 11 | } 12 | 13 | public class ThreadRunnable { 14 | public static void main(String[] args) { 15 | RunnableThread bullet1 = new RunnableThread(); 16 | Thread gun1 = new Thread(bullet1); 17 | 18 | RunnableThread2 bullet2 = new RunnableThread2(); 19 | Thread gun2 = new Thread(bullet2); 20 | 21 | gun1.start(); 22 | gun2.start(); 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Day32/ConsFromThread.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | class MyThr extends Thread { 4 | public MyThr(String name) { 5 | super(name); 6 | } 7 | @Override 8 | public void run() { 9 | int i = 30; 10 | System.out.println("Useless"); 11 | // while (true) { 12 | // System.out.println("I'm a thread"); 13 | // } 14 | } 15 | 16 | } 17 | 18 | public class ConsFromThread { 19 | public static void main(String[] args) { 20 | MyThr mt = new MyThr("DevvSakib"); 21 | MyThr t = new MyThr("Devv"); 22 | mt.start(); 23 | t.start(); 24 | System.out.println("The id of the thread is: " + mt.getId() + ' ' + t.getId()); 25 | System.out.println("The name of the thread is: " + mt.getName() + ' ' + t.getName()); 26 | } 27 | } 28 | /* 29 | * 30 | * Constructors 31 | * ========== 32 | * Thread() 33 | * Thread(String name) 34 | * Thread(Runnable r) 35 | * Thread(Runnable r, String name) 36 | * 37 | * 38 | */ -------------------------------------------------------------------------------- /Day32/LifeCycle.java: -------------------------------------------------------------------------------- 1 | package com; 2 | class RunnableThread implements Runnable { 3 | public void run() { 4 | System.out.println("Runnable thread 1 running"); 5 | } 6 | } 7 | 8 | class RunnableThread2 implements Runnable { 9 | public void run() { 10 | System.out.println("Runnable thread 2 running"); 11 | } 12 | } 13 | 14 | public class LifeCycle { 15 | public static void main(String[] args) { 16 | RunnableThread bullet1 = new RunnableThread(); 17 | Thread gun1 = new Thread(bullet1); 18 | 19 | RunnableThread2 bullet2 = new RunnableThread2(); 20 | Thread gun2 = new Thread(bullet2); 21 | 22 | gun1.start(); 23 | gun2.start(); 24 | 25 | } 26 | } 27 | /* 28 | * 1. New -> 2. Runnable -> 3. Running -> 4. Non Runnable(Blocked) Go back to 2-> 5. Terminated 29 | * 30 | * 1. New -> Instance of thread created which not yet started by invoking start(); 31 | * 32 | * 2. Runnable -> After invocation of start() & before it as selected to be run; 33 | * 34 | * 3. Running -> After thread sheduler has selected it; 35 | * 36 | * 4.Non Runnable -> Thread alive, but not eligible to run; 37 | * 38 | * 5. Terminated -> run() method has exitted; 39 | * 40 | */ -------------------------------------------------------------------------------- /Day32/com/ConsFromThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day32/com/ConsFromThread.class -------------------------------------------------------------------------------- /Day32/com/LifeCycle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day32/com/LifeCycle.class -------------------------------------------------------------------------------- /Day32/com/MyThr.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day32/com/MyThr.class -------------------------------------------------------------------------------- /Day32/com/RunnableThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day32/com/RunnableThread.class -------------------------------------------------------------------------------- /Day32/com/RunnableThread2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day32/com/RunnableThread2.class -------------------------------------------------------------------------------- /Day33/Practice.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | class PracticeA extends Thread { 4 | public void run() { 5 | while (true) { 6 | System.out.println("Good Morning"); 7 | } 8 | } 9 | } 10 | 11 | class PracticeB extends Thread { 12 | public void run() { 13 | // while (false) { 14 | // // try { 15 | // // Thread.sleep(40); 16 | // // } catch (InterruptedException e) { 17 | // // e.printStackTrace(); 18 | // // } 19 | // System.out.println("Welcome============="); 20 | // } 21 | } 22 | } 23 | 24 | public class Practice { 25 | public static void main(String[] args) { 26 | PracticeA pa = new PracticeA(); 27 | PracticeB pb = new PracticeB(); 28 | 29 | // p2 30 | // pa.setPriority(6); 31 | // pb.setPriority(9); 32 | // System.out.println(pa.getPriority()); // default prio - 5 33 | // System.out.println(pb.getPriority()); 34 | // System.out.println(pb.getState()); 35 | // pa.start(); 36 | pb.start(); 37 | // System.out.println(pb.getState()); 38 | 39 | System.out.println(Thread.currentThread().getState()); 40 | } 41 | 42 | } 43 | // javac -d . Practice.java && java com/Practice -------------------------------------------------------------------------------- /Day33/ThreadMethods.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | class MyThread1 extends Thread { 4 | public void run() { 5 | int i = 0; 6 | 7 | while (true) { 8 | System.out.println("MyThread 1: "); 9 | // try { 10 | // Thread.sleep(500); 11 | // } catch (InterruptedException e) { 12 | // e.printStackTrace(); 13 | // } 14 | i++; 15 | } 16 | } 17 | 18 | } 19 | 20 | class MyThread2 extends Thread { 21 | public void run() { 22 | while (true) { 23 | System.out.println("MyThread 2: "); 24 | } 25 | } 26 | 27 | } 28 | 29 | public class ThreadMethods { 30 | public static void main(String[] args) { 31 | MyThread1 t = new MyThread1(); 32 | MyThread2 t1 = new MyThread2(); 33 | 34 | t.start(); 35 | // try { 36 | // t.join(); 37 | // } catch (Exception e) { 38 | // System.out.println(e); 39 | // } 40 | t1.start(); 41 | } 42 | } 43 | /* 44 | * t2.start() will never start until t1 finish when use t.join(). 45 | * 46 | */ 47 | // javac -d . ThreadMethods.java && java com/ThreadMethods -------------------------------------------------------------------------------- /Day33/ThreadPriorities.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | class MyThread extends Thread { 4 | public MyThread(String name) { 5 | super(name); 6 | 7 | } 8 | 9 | public void run() { 10 | while (true) { 11 | System.out.println("I am Thread"); 12 | System.out.println("MyThread Running..." + this.getName()); 13 | } 14 | } 15 | } 16 | 17 | public class ThreadPriorities { 18 | public static void main(String[] args) { 19 | 20 | MyThread mt = new MyThread("1"); 21 | MyThread mt1 = new MyThread("2 (MIN_PRIORITY)"); 22 | MyThread mt2 = new MyThread("3"); 23 | MyThread mt3 = new MyThread("4 (MAX_PRIORITY)"); 24 | MyThread mt4 = new MyThread("5"); 25 | MyThread mt5 = new MyThread("6"); 26 | 27 | mt3.setPriority(Thread.MAX_PRIORITY); 28 | mt1.setPriority(Thread.MIN_PRIORITY); 29 | mt.start(); 30 | mt1.start(); 31 | mt2.start(); 32 | mt3.start(); 33 | } 34 | } 35 | 36 | /* 37 | * For example: In your home, you have the highest priority to your parent, if 38 | * your country PM come to your home, then your parent will give the highest 39 | * priority to PM. 40 | * 41 | * 42 | * Thread executing HIGHLY depend on OS 43 | * 44 | * 45 | */ 46 | 47 | // javac -d . ThreadPriorities.java && java com/ThreadPriorities -------------------------------------------------------------------------------- /Day33/com/MyThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day33/com/MyThread.class -------------------------------------------------------------------------------- /Day33/com/MyThread1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day33/com/MyThread1.class -------------------------------------------------------------------------------- /Day33/com/MyThread2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day33/com/MyThread2.class -------------------------------------------------------------------------------- /Day33/com/Practice.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day33/com/Practice.class -------------------------------------------------------------------------------- /Day33/com/PracticeA.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day33/com/PracticeA.class -------------------------------------------------------------------------------- /Day33/com/PracticeB.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day33/com/PracticeB.class -------------------------------------------------------------------------------- /Day33/com/ThreadMethods.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day33/com/ThreadMethods.class -------------------------------------------------------------------------------- /Day33/com/ThreadPriorities.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day33/com/ThreadPriorities.class -------------------------------------------------------------------------------- /Day34/Circle.java: -------------------------------------------------------------------------------- 1 | package com.shape; 2 | 3 | public class Circle extends Shape { 4 | Circle(int dim1) { 5 | super(dim1, -1); 6 | } 7 | 8 | public double area() { 9 | return Math.PI * this.dim1 * this.dim1; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Day34/Cylinder.java: -------------------------------------------------------------------------------- 1 | package com.shape; 2 | 3 | public class Cylinder extends Shape { 4 | Cylinder(int dim1, int dim2) { 5 | super(dim1, dim2); 6 | } 7 | 8 | public double area() { 9 | return 2 * Math.PI * this.dim1 * (this.dim2 + this.dim1); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Day34/Rect.java: -------------------------------------------------------------------------------- 1 | package com.shape; 2 | 3 | public class Rect extends Shape { 4 | Rect(int dim1, int dim2) { 5 | super(dim1, dim2); 6 | } 7 | public int area(){ 8 | return this.dim1 * this.dim2; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Day34/Shape.java: -------------------------------------------------------------------------------- 1 | package com.shape; 2 | 3 | public class Shape { 4 | int dim1, dim2; 5 | 6 | Shape(int dim1, int dim2) { 7 | this.dim1 = dim1; 8 | this.dim2 = dim2; 9 | } 10 | 11 | public int getDim1(int dim1) { 12 | return this.dim1; 13 | } 14 | 15 | public int getDim2(int dim2) { 16 | return this.dim2; 17 | } 18 | 19 | public void setDim1(int dim1) { 20 | this.dim1 = dim1; 21 | } 22 | 23 | public void setDim2(int dim2) { 24 | this.dim2 = dim2; 25 | } 26 | public static void main(String[] args) { 27 | 28 | } 29 | } -------------------------------------------------------------------------------- /Day34/Sphere.java: -------------------------------------------------------------------------------- 1 | package com.shape; 2 | 3 | public class Sphere extends Shape { 4 | Sphere(int dim1, int dim2) { 5 | super(dim1, dim2); 6 | } 7 | 8 | public int area() { 9 | return this.dim1 * this.dim2; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Day34/Square.java: -------------------------------------------------------------------------------- 1 | package com.shape; 2 | 3 | public class Square extends Shape { 4 | Square(int dim1, int dim2) { 5 | super(dim1, dim2); 6 | } 7 | 8 | public double area() { 9 | return 4 * Math.PI * (this.dim2 + this.dim1); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Day34/com/shape/Circle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day34/com/shape/Circle.class -------------------------------------------------------------------------------- /Day34/com/shape/Cylinder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day34/com/shape/Cylinder.class -------------------------------------------------------------------------------- /Day34/com/shape/Rect.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day34/com/shape/Rect.class -------------------------------------------------------------------------------- /Day34/com/shape/Shape.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day34/com/shape/Shape.class -------------------------------------------------------------------------------- /Day34/com/shape/Sphere.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day34/com/shape/Sphere.class -------------------------------------------------------------------------------- /Day34/com/shape/Square.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day34/com/shape/Square.class -------------------------------------------------------------------------------- /Day35/ErrorDemo.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import java.util.Scanner; 4 | 5 | public class ErrorDemo { 6 | public static void main(String[] args) { 7 | // write a program to print all prime numbesr between 1 to 10. 8 | // Logical error 9 | for (int i = 1; i < 5; i++) { 10 | // System.out.println(2 * i + 1); 11 | } 12 | 13 | // Runtime Error 14 | int k; 15 | Scanner sc = new Scanner(System.in); 16 | System.out.print("Enter a number: "); 17 | k = sc.nextInt(); 18 | System.out.println(100 / k); 19 | } 20 | } 21 | /* 22 | * untime error after: 23 | * Exception in thread "main" java.lang.ArithmeticException: / by zero 24 | * 25 | */ 26 | 27 | 28 | // run code: javac -d . ErrorDemo.java && java com/ErrorDemo -------------------------------------------------------------------------------- /Day35/ErrorException.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | public class ErrorException { 4 | public static void main(String[] args) { 5 | 6 | } 7 | } 8 | 9 | /* 10 | * Three type of error: 11 | * -------------------- 12 | * 1. Syntax -> int a = 5 | int a = a + b; | a =5; 13 | * 2. Logical/Bug -> 14 | * 3. Runtime 15 | * 16 | * 17 | */ -------------------------------------------------------------------------------- /Day35/com/ErrorDemo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day35/com/ErrorDemo.class -------------------------------------------------------------------------------- /Day35/com/ErrorException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day35/com/ErrorException.class -------------------------------------------------------------------------------- /Day36/HandleException.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import java.util.Scanner; 4 | 5 | public class HandleException { 6 | public static void main(String[] args) { 7 | int[] marks = new int[5]; 8 | marks[0] = 12; 9 | marks[1] = 11; 10 | marks[2] = 32; 11 | Scanner sc = new Scanner(System.in); 12 | System.out.print("Enter array index: "); 13 | int ind = sc.nextInt(); 14 | 15 | System.out.print("Enter number to divide value with: "); 16 | int number = sc.nextInt(); 17 | 18 | try { 19 | System.out.println("The value at array index is: " + marks[ind]); 20 | System.out.println("The value of numebr is: " + marks[ind] / number); 21 | 22 | } catch (ArithmeticException e) { 23 | System.out.println("Arithmetic exception occured"); 24 | System.out.println(e); 25 | } catch (ArrayIndexOutOfBoundsException e) { 26 | System.out.println("Aray exception occured"); 27 | System.out.println(e); 28 | }catch (Exception e) { 29 | System.out.println("Some exception occured"); 30 | System.out.println(e); 31 | } 32 | } 33 | } 34 | 35 | // javac -d . HandleException.java && java com/HandleException -------------------------------------------------------------------------------- /Day36/NestedTryCatch.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import java.util.Scanner; 4 | 5 | public class NestedTryCatch { 6 | public static void main(String[] args) { 7 | int[] marks = new int[4]; 8 | marks[0] = 12; 9 | marks[1] = 11; 10 | marks[2] = 32; 11 | Scanner sc = new Scanner(System.in); 12 | boolean cond = true; 13 | while (cond) { 14 | System.out.print("Enter array index: "); 15 | int ind = sc.nextInt(); 16 | try { 17 | // System.out.println("The value at array index is: " + marks[ind]); 18 | // System.out.println("The value of numebr is: " + marks[ind] / number); 19 | System.out.println("Nested block"); 20 | 21 | try { 22 | System.out.println(marks[ind]); 23 | cond = false; 24 | 25 | } catch (ArrayIndexOutOfBoundsException e) { 26 | System.out.println("Sorry, index is out of bound. Please enter valid index"); 27 | System.out.println("Exception Level 2"); 28 | } 29 | 30 | } catch (Exception e) { 31 | System.out.println("Exception Level 1"); 32 | } 33 | } 34 | } 35 | } 36 | 37 | // javac -d . NestedTryCatch.java && java com/NestedTryCatch -------------------------------------------------------------------------------- /Day36/com/HandleException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day36/com/HandleException.class -------------------------------------------------------------------------------- /Day36/com/NestedTryCatch.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day36/com/NestedTryCatch.class -------------------------------------------------------------------------------- /Day37/ExceptionClass.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | class MyException extends Exception { 4 | @Override 5 | public String toString() { 6 | return super.toString() + "I am toString()"; 7 | } 8 | 9 | @Override 10 | public String getMessage() { 11 | return super.getMessage() + "I am getMessage()"; 12 | } 13 | } 14 | 15 | public class ExceptionClass { 16 | public static void main(String[] args) { 17 | int a = 10; 18 | if (a < 12) { 19 | try { 20 | // throw new MyException(); 21 | throw new ArithmeticException(); 22 | 23 | } catch (Exception e) { 24 | System.out.println(e.getMessage()); 25 | System.out.println(e.toString()); 26 | e.printStackTrace(); 27 | System.out.println(e); // toString method run 28 | } 29 | } 30 | } 31 | } 32 | 33 | /* 34 | * We can write custom Exception susing Exception class in Java. 35 | * String toString() -> 36 | * Void printStackTrace() -> 37 | * String getMessage() -> 38 | * 39 | * We can throw our custom exception using "throw". 40 | * 41 | */ 42 | 43 | // javac -d . ExceptionClass.java && java com/ExceptionClass -------------------------------------------------------------------------------- /Day37/ThrowVsThrows.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | class NegativeExceptions extends Exception { 4 | @Override 5 | public String toString() { 6 | return "Radius Cann't be negative"; 7 | } 8 | 9 | public String getMessage() { 10 | return "Radius Cann't be negative"; 11 | } 12 | } 13 | 14 | public class ThrowVsThrows { 15 | public static double area(int r) throws NegativeExceptions { 16 | if (r < 0) { 17 | throw new NegativeExceptions(); 18 | } 19 | return Math.PI * r * r; 20 | } 21 | 22 | public static int divide(int a, int b) throws ArithmeticException { 23 | int result = a / b; 24 | return result; 25 | } 26 | 27 | public static void main(String[] args) { 28 | 29 | try { 30 | // double c = area(10); 31 | double c = area(-1); 32 | System.out.println(c); 33 | } catch (Exception e) { 34 | // System.out.println("Exception"); 35 | System.out.println(e.getMessage()); 36 | } 37 | } 38 | } 39 | 40 | /* 41 | * Throw: 42 | * Throw is use to throw an exception to stop the programmer immediately. 43 | * 44 | * Throws: 45 | * Use to alert other that my programme can throw exception. Thats mean I have 46 | * to handle it with TryCatch. 47 | * 48 | */ 49 | // javac -d . ThrowVsThrows.java && java com/ThrowVsThrows -------------------------------------------------------------------------------- /Day37/com/ExceptionClass.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day37/com/ExceptionClass.class -------------------------------------------------------------------------------- /Day37/com/MyException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day37/com/MyException.class -------------------------------------------------------------------------------- /Day37/com/NegativeExceptions.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day37/com/NegativeExceptions.class -------------------------------------------------------------------------------- /Day37/com/ThrowVsThrows.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day37/com/ThrowVsThrows.class -------------------------------------------------------------------------------- /Day38/FinallyBlock.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | public class FinallyBlock { 4 | public static int greet() { 5 | try { 6 | int a = 5; 7 | int b = 0; 8 | int c = a / b; 9 | return c; 10 | } catch (Exception e) { 11 | System.out.println(e); 12 | } finally { 13 | System.out.println("Ending of progrmme"); 14 | } 15 | return 0; // if programme don't go to try. 16 | } 17 | 18 | public static int loops() { 19 | for (int i = 0; i < 10; i++) { 20 | try { 21 | if (i == 2) { 22 | break; 23 | } 24 | } catch (Exception e) { 25 | System.out.println(e); 26 | } finally { 27 | System.out.format("i == %d, still execute after break ", i); 28 | System.out.println(); 29 | } 30 | } 31 | return 0; 32 | } 33 | 34 | public static void main(String[] args) { 35 | int k = greet(); 36 | // System.out.println(k); 37 | loops(); 38 | } 39 | } 40 | 41 | /* 42 | * Finally block code execute no matter what happens. 43 | * In greet() function, programme return with c value but finally block return 44 | * as well. 45 | * 46 | * 47 | */ 48 | 49 | // javac -d . FinallyBlock.java && java com/FinallyBlock -------------------------------------------------------------------------------- /Day38/Practice.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Practice { 6 | public static void main(String[] args) { 7 | // problem 1 8 | // syntax error - int a = 4 9 | 10 | // problem 2 11 | // try { 12 | // int a = 66/9; 13 | // System.out.println(a); 14 | // } catch (IllegalArgumentException e) { 15 | // System.out.println("Haha"); 16 | // }catch(ArithmeticException e){ 17 | // System.out.println("Hihi"); 18 | // } 19 | 20 | // problem 3 21 | boolean flag = true; 22 | int[] marks = new int[3]; 23 | marks[0] = 34; 24 | marks[1] = 24; 25 | marks[2] = 54; 26 | Scanner sc = new Scanner(System.in); 27 | int index; 28 | int i = 0; 29 | while (flag) { 30 | try { 31 | System.out.print("index: "); 32 | index = sc.nextInt(); 33 | System.out.println("marks[ind] is: " + marks[index]); 34 | System.out.println("You entered invalid index: " + i + " times."); 35 | break; 36 | } catch (Exception e) { 37 | System.out.println("Invalid Index."); 38 | i++; 39 | } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Day38/com/FinallyBlock.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day38/com/FinallyBlock.class -------------------------------------------------------------------------------- /Day38/com/Practice.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day38/com/Practice.class -------------------------------------------------------------------------------- /Day39/CollectionFramework.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | public class CollectionFramework { 4 | 5 | } 6 | 7 | /* 8 | * Collections Framework: 9 | * ---------------- 10 | * A collection represents a group of object. Java Collections provide Classes 11 | * and Intergaces for us to be able to write Code quickly and efficiently 12 | * 13 | * Why Collections? 14 | * ---------------- 15 | * We need collections for efficient storage and better manupulation of data in 16 | * Java. 17 | * 18 | * Ex: we use arrays to store integers but what if we want to: 19 | * Resize 20 | * Insert element in between 21 | * Delte 22 | * Apply certain operation 23 | * 24 | * How are collections Available? 25 | * ----------------------------- 26 | * They are in java.util.Collections 27 | * * Class and Interfaces 28 | * 29 | * ArrayList -> Variable size collection 30 | * Set -> Distinct Collection 31 | * Stack -> Lifo data structure(Last In, First Out) 32 | * Hashmap -> Storing key-value pairs 33 | * 34 | * Collection also provide 35 | * 36 | */ 37 | -------------------------------------------------------------------------------- /Day39/CollectionsHierarchy.java: -------------------------------------------------------------------------------- 1 | package Day39; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Set; 5 | import java.util.TreeSet; 6 | 7 | public class CollectionsHierarchy { 8 | public static void main(String[] args) { 9 | // TreeSet 10 | // Set 11 | // ArrayList 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Day4/AssociativityJava.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day4/AssociativityJava.class -------------------------------------------------------------------------------- /Day4/AssociativityJava.java: -------------------------------------------------------------------------------- 1 | public class AssociativityJava { 2 | public static void main(String[] args) { 3 | // Precedence & Associativity 4 | int x = 5 * 12 - 30 / 2; 5 | /* 6 | * Precedence 7 | * 5*12 = 60 8 | * 30/2 = 15 9 | * 60 - 15 = 45 10 | */ 11 | int y = 20 / 5 - 30 * 2; 12 | /* 13 | * / === * -> Left to Right 14 | * Associativity 15 | * 20/5 = 4 16 | * 30*2 = 60 17 | * 44 - 60 = -56 18 | */ 19 | // System.out.println(y); 20 | /* 21 | * 22 | * + - less precedence * / 23 | * x => first *, second /, third -, 24 | * +, - --> Left to Right 25 | * ++, = --> Right to Left 26 | */ 27 | // TASK 28 | int a = 1; 29 | int c = 2; 30 | int task1 = (x - y) / 2; 31 | int task2 = ((x * x) - (4 * a * c)) / (2 * a); 32 | System.out.println(task1); 33 | System.out.println(task2); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Day4/Operators.java: -------------------------------------------------------------------------------- 1 | public class OperatorsJava { 2 | public static void main(String[] args) { 3 | // System.out.println("Hello Day4!"); 4 | int a = 1; 5 | // int b = 2 + a; 6 | // int b = 2 * a; 7 | // int b = 16 % 3; // modulo operator 8 | int b = 16 / 3; 9 | a += b; 10 | // System.out.println(b); 11 | // System.out.println(b == a); 12 | // System.out.println(b != a); 13 | // System.out.println(b > a); 14 | // Logical 15 | // System.out.println((2>4 && 4 > 1) || 5<10); 16 | 17 | // || or- one true/false 18 | 19 | // Bitwuse 20 | int x = 10; 21 | // System.out.println(x&3); 22 | 23 | System.out.println(4.52%1); 24 | 25 | 26 | } 27 | } 28 | 29 | // Operators are used to perform operations on variables and values 30 | 31 | // Type of 32 | // Arithmetic -> +, -, /, *, ++, -- 33 | // Assignment -> =, +=, -= 34 | // Comparison -> ==, >=, <= 35 | // Logical -> &&, ||, ! 36 | // Bitwise -> &, | 37 | 38 | // Arithmetic operators cnnt work with booleans 39 | // % can work with float, double -------------------------------------------------------------------------------- /Day4/Type_Conversion_Precedence_and_Associativity__8oLmD9g.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day4/Type_Conversion_Precedence_and_Associativity__8oLmD9g.jpg -------------------------------------------------------------------------------- /Day40/ArrayDequeJava.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import java.util.ArrayDeque; 4 | 5 | public class ArrayDequeJava { 6 | public static void main(String[] args) { 7 | ArrayDeque ad = new ArrayDeque<>(); 8 | ArrayDeque ad2 = new ArrayDeque<>(); 9 | ad2.add("devv"); 10 | ad2.add("sakib"); 11 | 12 | ad.add(123); 13 | ad.add(132); 14 | ad.add(12); 15 | ad.add(2); 16 | ad.addFirst(-12); 17 | 18 | System.out.println(ad.getFirst()); 19 | // System.out.println(ad2); 20 | } 21 | } 22 | // javac -d . ArrayDequeJava.java && java com/ArrayDequeJava -------------------------------------------------------------------------------- /Day40/ArrayListJava.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import java.util.*; 4 | // * => import all; 5 | 6 | public class ArrayListJava { 7 | public static void main(String[] args) { 8 | ArrayList l1 = new ArrayList<>(); 9 | ArrayList l2 = new ArrayList<>(1); 10 | l1.add(56); 11 | l1.add(63); 12 | l1.add(5); 13 | l1.add(3); 14 | l1.add(0, 8); 15 | l1.add(0, 1); 16 | 17 | l2.add(12); 18 | l2.add(12); 19 | l2.addAll(l1); 20 | // l2.add(12); // will not add to the list 21 | 22 | l2.set(0, null); 23 | System.out.println(l2); 24 | l1.clear(); 25 | int i = 0; 26 | // while (i < l1.size()) { 27 | // System.out.println(l2.get(i)); 28 | // i++; 29 | // } 30 | // System.out.println(l2.contains(12)); // true 31 | // System.out.println(l2.indexOf(12)); // get index of the given element 32 | // System.out.println(l2.indexOf(-12)); // if not, return -1 33 | } 34 | } 35 | // javac -d . ArrayListJava.java && java com/ArrayListJava -------------------------------------------------------------------------------- /Day40/LinkedListJava.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import java.util.*; 4 | 5 | public class LinkedListJava { 6 | public static void main(String[] args) { 7 | LinkedList ls = new LinkedList<>(); 8 | LinkedList lss = new LinkedList<>(); 9 | ls.add(56); 10 | ls.add(63); 11 | ls.add(5); 12 | ls.add(3); 13 | ls.add(0, 8); 14 | ls.add(0, 1); 15 | 16 | lss.add(12); 17 | lss.add(12); 18 | lss.addAll(ls); 19 | lss.addLast(34); // 20 | lss.addFirst(34); // 21 | lss.removeFirst(); // 22 | 23 | 24 | System.out.println(lss); 25 | 26 | int i = 0; 27 | } 28 | } 29 | 30 | /* 31 | * LinkedList: 32 | * ---------- 33 | * All value linked with each other. 34 | * Value regerece -> Prev, Next 35 | * 36 | * ------- Head ----------------------- Tail 37 | * Nil <- value <-> value <-> value <-> value <-> nil 38 | * 39 | * 40 | * 41 | * 42 | */ 43 | 44 | // javac -d . LinkedListJava.java && java com/LinkedListJava -------------------------------------------------------------------------------- /Day40/com/ArrayDequeJava.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day40/com/ArrayDequeJava.class -------------------------------------------------------------------------------- /Day40/com/ArrayListJava.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day40/com/ArrayListJava.class -------------------------------------------------------------------------------- /Day40/com/LinkedListJava.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day40/com/LinkedListJava.class -------------------------------------------------------------------------------- /Day41/Day41/HashMapJava.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day41/Day41/HashMapJava.class -------------------------------------------------------------------------------- /Day41/HashMapJava.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | // Practic section 7 | class Book { 8 | private String name; 9 | private String author; 10 | private String isbn; 11 | 12 | public void setDetails(String name, String author, String isbn) { 13 | this.name = name; 14 | this.author = author; 15 | this.isbn = isbn; 16 | } 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public String getAuthor() { 23 | return author; 24 | } 25 | 26 | public String getIsbn() { 27 | return isbn; 28 | } 29 | } 30 | 31 | // Practic section 32 | public class HashMapJava { 33 | // public static void main(String[] args) { 34 | // HashMap hm = new HashMap<>(); 35 | // hm.put("first", "Devv"); 36 | // hm.put("last", "Sakib"); 37 | 38 | // hm.remove("first"); 39 | // System.out.println(hm.get("first")); // null 40 | // System.out.println(hm.get("last").toLowerCase()); // sakib 41 | // // System.out.println(hm); 42 | // } 43 | 44 | // Practicing HashMap 45 | private Map books = new HashMap<>(); 46 | 47 | public void addBook(String isbn, String name, String author) { 48 | Book book = new Book(); 49 | book.setDetails(name, author, isbn); 50 | books.put(isbn, book); 51 | } 52 | 53 | public Book getBook(String isbn) { 54 | return books.get(isbn); 55 | } 56 | 57 | public static void main(String[] args) { 58 | HashMapJava collection = new HashMapJava(); 59 | collection.addBook("21373", "A Coder With Zero Knowledge", "DevvSakib"); 60 | collection.addBook("1234567890", "The Catcher in the Rye", "J.D. Salinger"); 61 | // Book b1 = collection.getBook("21232"); 62 | Book book1 = collection.getBook("1234567890"); 63 | Book book2 = collection.getBook("21373"); 64 | if (book1 != null || book2 != null) { 65 | System.out.println("Book 1: " + book1.getName() + " by " + book1.getAuthor()); 66 | System.out.println("Book 2: " + book2.getName() + " by " + book2.getAuthor()); 67 | } else { 68 | System.out.println("Book 1 not found."); 69 | } 70 | 71 | } 72 | // Practicing HashMap 73 | 74 | } 75 | /* 76 | * n Java, a HashMap is a collection class that allows you to store elements in 77 | * the form of key-value pairs. It implements the Map interface and is a part of 78 | * the Java Collections Framework. 79 | * 80 | * 81 | * HashMaps are commonly used in Java when you need to store and retrieve 82 | * elements based on unique keys. 83 | * 84 | * Caching, Indexing, Counting, Grouping, 85 | * 86 | */ 87 | // javac -d . HashMapJava.java && java com/HashMapJava -------------------------------------------------------------------------------- /Day41/HashSetJava.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import java.util.HashSet; 4 | 5 | public class HashSetJava { 6 | public static void main(String[] args) { 7 | HashSet myHashSet = new HashSet<>(); 8 | myHashSet.add(12); 9 | myHashSet.add(12); 10 | myHashSet.add(15); 11 | myHashSet.add(8); 12 | myHashSet.add(10); 13 | System.out.println(myHashSet); 14 | } 15 | } 16 | 17 | /* 18 | In Java, a HashSet is a collection class that implements the Set interface and allows you to store elements in a collection with no duplicates. It is a part of the Java Collections Framework. 19 | */ 20 | 21 | 22 | // javac -d . HashSetJava.java && java com/HashSetJava -------------------------------------------------------------------------------- /Day41/HashingTechn.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | public class HashingTechn { 4 | public static void main(String[] args) { 5 | 6 | } 7 | } 8 | 9 | /* 10 | * Hashing Technique 11 | * ----------------- 12 | * Hash Collision 13 | * Open Addressing to handle collision 14 | * chainning 15 | * 16 | * Class: 17 | * HashSet 18 | * HashMap 19 | * LinkedHashMap 20 | * HashMap 21 | * 22 | * 23 | */ 24 | 25 | // javac -d . HashMap.java && java com/HashMap -------------------------------------------------------------------------------- /Day41/com/Book.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day41/com/Book.class -------------------------------------------------------------------------------- /Day41/com/HashMap.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day41/com/HashMap.class -------------------------------------------------------------------------------- /Day41/com/HashMapJava.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day41/com/HashMapJava.class -------------------------------------------------------------------------------- /Day41/com/HashSetJava.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day41/com/HashSetJava.class -------------------------------------------------------------------------------- /Day42/CalendarClass.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import java.util.Calendar; 4 | import java.util.TimeZone; 5 | 6 | public class CalendarClass { 7 | public static void main(String[] args) { 8 | // Gregorian Calender 9 | // Calendar c = Calendar.getInstance(); 10 | // System.out.println(c.getCalendarType()); 11 | // System.out.println(c.getTimeZone()); 12 | 13 | Calendar c = Calendar.getInstance(TimeZone.getTimeZone("Asia/Dhaka")); 14 | System.out.println(c.getCalendarType()); 15 | System.out.println(c.getTimeZone().getID()); 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Day42/DateClass.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import java.util.Date; 4 | 5 | public class DateClass{ 6 | public static void main(String[] args) { 7 | // Date d = new Date(); 8 | Date d = new Date(); 9 | System.out.println(d.getTime()); 10 | // System.out.println(d.getDate()); Deprecated 11 | // System.out.println(d.getYear()); Deprecated 12 | // System.out.println(d.getSeconds()); Deprecated 13 | 14 | } 15 | } 16 | 17 | 18 | /* 19 | Date class 20 | 21 | Date d = new Date() 22 | */ -------------------------------------------------------------------------------- /Day42/DateTime.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | public class DateTime { 4 | public static void main(String[] args) { 5 | System.out.println(System.currentTimeMillis() / 1000/3600/24/365); 6 | } 7 | } 8 | 9 | /* 10 | * How java stores a Date? 11 | * Date in java is stored in the form of a long number. This long number holds 12 | * the number of ms passed since 1 jan 1970. 13 | * 14 | * Java assumes that 1900 is the start year which means it calculates year 15 | * passed since 1900 whenever we ask it for year passed. 16 | * 17 | * System.CurrentTimeMillis() 18 | */ 19 | 20 | // javac -d . DateTime.java && java com/DateTime -------------------------------------------------------------------------------- /Day42/GregrianCal.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import java.util.Calendar; 4 | import java.util.GregorianCalendar; 5 | import java.util.concurrent.Callable; 6 | 7 | public class GregrianCal { 8 | public static void main(String[] args) { 9 | Calendar c = Calendar.getInstance(); 10 | 11 | System.out.println(c.getTime()); 12 | // System.out.println(c.getTimeZone()); 13 | // System.out.println(c.get(Calendar.DATE)); 14 | // System.out.println(c.get(Calendar.HOUR)); 15 | // System.out.println(c.get(Calendar.HOUR_OF_DAY)); 16 | 17 | GregorianCalendar gc = new GregorianCalendar(); 18 | System.out.println(gc.isLeapYear(2020)); // true/false 19 | System.out.println(gc.getFirstDayOfWeek()); 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Day42/com/CalendarClass.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day42/com/CalendarClass.class -------------------------------------------------------------------------------- /Day42/com/DateClass.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day42/com/DateClass.class -------------------------------------------------------------------------------- /Day42/com/DateTime.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day42/com/DateTime.class -------------------------------------------------------------------------------- /Day42/com/GregrianCal.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day42/com/GregrianCal.class -------------------------------------------------------------------------------- /Day43/DTFormatter.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import java.time.LocalDateTime; 4 | import java.time.format.DateTimeFormatter; 5 | 6 | public class DTFormatter { 7 | public static void main(String[] args) { 8 | LocalDateTime dt = LocalDateTime.now(); 9 | // System.out.println(dt); 10 | 11 | 12 | DateTimeFormatter df = DateTimeFormatter.ofPattern("dd-yyyy-mm -- E m"); 13 | 14 | DateTimeFormatter df2 = DateTimeFormatter.ISO_LOCAL_DATE; 15 | 16 | 17 | String myDate = dt.format(df); 18 | System.out.println(myDate); 19 | 20 | } 21 | } 22 | 23 | /* 24 | Format date as you want. 25 | Example: 12-15-2222, 2222-12-15, 15-2222-12, 12-2222-15 26 | */ 27 | 28 | // javac -d . DTFormatter.java && java com/DTFormatter -------------------------------------------------------------------------------- /Day43/Practice.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Calendar; 5 | import java.util.Date; 6 | import java.util.HashSet; 7 | 8 | public class Practice { 9 | public static void main(String[] args) { 10 | 11 | // P1 12 | ArrayList ar = new ArrayList<>(); 13 | ar.add("S 1"); 14 | ar.add("S 2"); 15 | ar.add("S 3"); 16 | ar.add("S 4"); 17 | ar.add("S 5"); 18 | 19 | for(Object o : ar){ 20 | // System.out.println(o); 21 | } 22 | 23 | 24 | // P2 25 | HashSet s = new HashSet<>(); 26 | 27 | s.add(12); 28 | s.add(14); 29 | s.add(42); 30 | s.add(18); 31 | s.add(12); 32 | 33 | // System.out.println(s); 34 | 35 | // P3 36 | Calendar c = Calendar.getInstance(); 37 | System.out.println(c.get(Calendar.HOUR) + ":" + c.get(Calendar.MINUTE)); 38 | 39 | 40 | // P4 41 | 42 | 43 | } 44 | } 45 | // avac -d . Practice.java && java com/Practice -------------------------------------------------------------------------------- /Day43/PracticeCalc.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | class InvalidInputException extends Exception { 4 | @Override 5 | public String toString() { 6 | return "string"; 7 | } 8 | 9 | public String getMessage() { 10 | return "Cannot add 8 and 9"; 11 | } 12 | } 13 | class CannotDivideByZero extends Exception { 14 | @Override 15 | public String toString() { 16 | return "string"; 17 | } 18 | 19 | public String getMessage() { 20 | return "Cannot divide by 0"; 21 | } 22 | } 23 | 24 | class CustomCalculator { 25 | double add(double a, double b) throws InvalidInputException { 26 | 27 | if (a == 8 || b == 9) { 28 | 29 | throw new InvalidInputException(); 30 | } 31 | 32 | return a + b; 33 | } 34 | 35 | double substract(double a, double b) { 36 | return a - b; 37 | } 38 | 39 | double multiply(double a, double b) { 40 | return a * b; 41 | } 42 | 43 | double divide(double a, double b) throws CannotDivideByZero { 44 | if (b==0) { 45 | throw new CannotDivideByZero(); 46 | } 47 | return a / b; 48 | } 49 | } 50 | 51 | public class PracticeCalc { 52 | public static void main(String[] args) throws InvalidInputException { 53 | CustomCalculator c = new CustomCalculator(); 54 | System.out.println(c.add(9, 2)); 55 | System.out.println(c.divide(9, 0)); 56 | } 57 | } 58 | 59 | // you have to throw Exception -------------------------------------------------------------------------------- /Day43/TimeAPI.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import java.time.*; 4 | 5 | public class TimeAPI { 6 | public static void main(String[] args) { 7 | LocalDate dn = LocalDate.now(); 8 | LocalTime lt = LocalTime.now(); 9 | LocalDateTime ldt = LocalDateTime.now(); 10 | 11 | 12 | System.out.println(dn); 13 | System.out.println(lt.getHour()); 14 | System.out.println(ldt); 15 | } 16 | } 17 | 18 | 19 | /* 20 | Java.time package 21 | LocalDate 22 | LocalTime 23 | LocalDateTime 24 | DateTimeFormatter 25 | 26 | */ 27 | 28 | // javac -d . TimeAPI.java && java com/TimeAPI -------------------------------------------------------------------------------- /Day43/com/CannotDivideByZero.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day43/com/CannotDivideByZero.class -------------------------------------------------------------------------------- /Day43/com/CustomCalculator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day43/com/CustomCalculator.class -------------------------------------------------------------------------------- /Day43/com/DTFormatter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day43/com/DTFormatter.class -------------------------------------------------------------------------------- /Day43/com/InvalidInputException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day43/com/InvalidInputException.class -------------------------------------------------------------------------------- /Day43/com/Practice.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day43/com/Practice.class -------------------------------------------------------------------------------- /Day43/com/PracticeCalc.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day43/com/PracticeCalc.class -------------------------------------------------------------------------------- /Day43/com/TimeAPI.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day43/com/TimeAPI.class -------------------------------------------------------------------------------- /Day5/Practice.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day5/Practice.class -------------------------------------------------------------------------------- /Day5/Practice.java: -------------------------------------------------------------------------------- 1 | import java.u3til.Scanner; 2 | 3 | public class Practice { 4 | public static void main(String[] args) { 5 | // int v, u, a, s; 6 | // v = 5; 7 | // u = 2; 8 | // a = 1; 9 | // s = 5; 10 | // int x = (v * v - u * u) / (2 * a * s); 11 | // System.out.println(x); 12 | // char grade = 'B'; 13 | // grade = (char) (grade - 8); 14 | // System.out.println(grade); 15 | Scanner sc = new Scanner(System.in); 16 | int a = sc.nextInt(); 17 | System.out.println(a > 8); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Day5/ResultingDataType.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day5/ResultingDataType.class -------------------------------------------------------------------------------- /Day5/ResultingDataType.java: -------------------------------------------------------------------------------- 1 | public class ResultingDataType { 2 | public static void main(String[] args) { 3 | // flaot + int = float 4 | // float t = 654.5f + 6; 5 | // byte x = 5; 6 | // int y = 5; 7 | // short z = 3; 8 | // int a = y + z; 9 | // System.out.println(a); 10 | // Increment and Decrement Operators 11 | // int i = 54; 12 | // int p = i++; 13 | 14 | // use i first, it no matter to what 15 | // System.out.println(p); // 54 16 | // System.out.println(i++); 17 | // i increased by 1 18 | // System.out.println(i); 19 | // first increase i then print 20 | // System.out.println(++i); 21 | // i increased to 56 22 | // System.out.println(i); 23 | // System.out.println(i++); 24 | // System.out.println(i); 25 | // System.out.println(--i); 26 | 27 | // char 28 | char a = 'A'; 29 | System.out.println(a++); // A 30 | System.out.println(++a); // C 31 | } 32 | } 33 | 34 | // byte + short ---> int 35 | // int + short ---> int 36 | // long + float ---> float 37 | // int + float ---> float 38 | // char + int ---> int 39 | // char + short ---> int 40 | // long + double ---> double 41 | // flaot + double ---> double 42 | -------------------------------------------------------------------------------- /Day6/StringMethod.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day6/StringMethod.class -------------------------------------------------------------------------------- /Day6/StringMethod.java: -------------------------------------------------------------------------------- 1 | public class StringMethod { 2 | public static void main(String[] args) { 3 | String name = "devvSakib"; 4 | name = "DevvSakib"; 5 | String trimString = " Devv Sakib "; 6 | // System.out.println(name.length()); 7 | // System.out.println(name.toLowerCase()); 8 | // System.out.println(name.toUpperCase()); 9 | // System.out.println(name.charAt(2)); 10 | // System.out.println(trimString.trim()); 11 | // System.out.println(name.substring(0)); 12 | // System.out.println(name.substring(1, 5)); // evvS 13 | // System.out.println(name.replace('D', 'T')); 14 | // System.out.println(name.replace("v", "Dev")); 15 | // System.out.println(name.startsWith("D")); 16 | // System.out.println(name.endsWith("D")); 17 | // System.out.println(name.indexOf("v", 4)); 18 | // System.out.println(name.lastIndexOf("v")); 19 | // System.out.println(name.equals("DevvSakib")); 20 | System.out.println(name.equalsIgnoreCase("devvSakib")); 21 | 22 | /* 23 | * string length = .length() 24 | * string hashcode = .hashCode() 25 | * string lowercase = .toLowerCase() 26 | * string uppercase = .toUpperCase() 27 | * char index in sting = .charAt() 28 | * remove whitespace from string(end,start) = .trim() 29 | * start from given index = .substring(x) 30 | * start from end, given index = .substring(x,y) 31 | * replace char in string = .replace(s1,s2) 32 | * string start with = .startWith(s) bool 33 | * string ends with = .endsWith(s) bool 34 | * char index in string = .indexOf("v") 35 | * start char index in string = .indexOf(s,2) 36 | * last char index in string = .lastIndexOf(s) 37 | * from last char index in string = .lastIndexOf(s, 4) 38 | * string equals = .equals(s) bool 39 | * string equals ignore case = .equalsIgnoreCase(s) 40 | */ 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Day6/Strings.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day6/Strings.class -------------------------------------------------------------------------------- /Day6/Strings.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class Strings { 4 | public static void main(String[] args) { 5 | String name = new String("Hello DevvSakib"); 6 | // System.out.println(name); 7 | int a = 5; 8 | float b = 5.524f; 9 | 10 | // System.out.printf("the value %d of a: %10.2f", a, b); 11 | // %10.2f -> 10 = 10 space, .2 -> first 2 decimal 12 | // System.out.format("the value %d of a: %f", a, b); 13 | // Scanner sc = new Scanner(System.in); 14 | // String st = sc.next(); 15 | // String st = sc.nextLine(); 16 | // System.out.println(st); 17 | 18 | /* 19 | * next() => take first word 20 | * nextLine() => take all word 21 | * 22 | * 23 | * printf or format 24 | * 25 | * 26 | * %d --> format spacifier 27 | * %d -> int 28 | * %f -> float 29 | * %c -> char 30 | * %s -> string 31 | */ 32 | 33 | } 34 | } 35 | /* 36 | * A string is a sequence of characters. 37 | * String name = new String("DevvSakib") 38 | * 39 | * String is a class but can be use like a data type 40 | * 41 | * string are immutable, cant be change 42 | * 43 | * 44 | */ -------------------------------------------------------------------------------- /Day7/PracticeDay.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day7/PracticeDay.class -------------------------------------------------------------------------------- /Day7/PracticeDay.java: -------------------------------------------------------------------------------- 1 | import javax.swing.text.AbstractDocument.LeafElement; 2 | 3 | public class PracticeDay { 4 | public static void main(String[] arggs) { 5 | // Excercise 1 Lowercase 6 | String name = "DEVVSAKIB"; 7 | System.out.println(name.toLowerCase()); 8 | 9 | // Excercise 2 Replace 10 | String replaceWithUscr = "Devv Sakib"; 11 | System.out.println(replaceWithUscr.replace(" ", "_")); 12 | 13 | // Excercise 3 Replace 14 | String letter = "Hi <|name|>, Thank you"; 15 | System.out.println(letter.replace("<|name|>", "DevvSakib")); 16 | 17 | // Excercise 4 Detect 2/3pl spaces 18 | String doubleSpaces = "This is double spaces "; 19 | System.out.println(doubleSpaces.indexOf(" ")); 20 | System.out.println(doubleSpaces.indexOf(" ")); // false 21 | 22 | // Excercise 5 Format using escap sequence 23 | String ltr = "HI \n\tThis is Java of 100 Days"; 24 | System.out.println(ltr); 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Day8/ControlFlow.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day8/ControlFlow.class -------------------------------------------------------------------------------- /Day8/ControlFlow.java: -------------------------------------------------------------------------------- 1 | public class ControlFlow { 2 | public static void main(String[] args) { 3 | int age = 28; 4 | boolean test = age == 18; 5 | if (test) { 6 | System.out.println("You passed!"); 7 | } 8 | else{ 9 | System.out.println("Not accepted."); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Day8/Relational.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day8/Relational.class -------------------------------------------------------------------------------- /Day8/Relational.java: -------------------------------------------------------------------------------- 1 | public class Relational { 2 | public static void main(String[] args) { 3 | // if (2 > 2 && 2 < 3) { 4 | // System.out.println(true); 5 | // }else{ 6 | // System.out.println(false); 7 | // } 8 | 9 | // if (2 > 5 || 2 < 3) { 10 | // System.out.println(true); 11 | // }else{ 12 | // System.out.println(false); 13 | // } 14 | 15 | // if (2 > 5 != 2 < 3) { 16 | // System.out.println(true); 17 | // }else{ 18 | // System.out.println(false); 19 | // } 20 | 21 | if (!(2 > 5)) { 22 | System.out.println(true); 23 | } else if ((5 > 2)) { 24 | System.out.println(true); 25 | } else { 26 | System.out.println(false); 27 | } 28 | 29 | } 30 | } 31 | 32 | /* 33 | * Relational Operators 34 | * == -> equal 35 | * != -> not equal 36 | * > -> greater 37 | * < -> less 38 | * <= -> eq g 39 | * >= -> eq l 40 | * && -> and (most commonly used) 41 | * || -> or (most commonly used) 42 | * ! -> not (most commonly used) 43 | * 44 | * 45 | */ -------------------------------------------------------------------------------- /Day8/SwitchJava.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day8/SwitchJava.class -------------------------------------------------------------------------------- /Day8/SwitchJava.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class SwitchJava { 4 | public static void main(String[] args) { 5 | // int age = 40; 6 | Scanner sc = new Scanner(System.in); 7 | System.out.print("Enter your age: "); 8 | int age = sc.nextInt(); 9 | 10 | // if (age > 49) { 11 | // System.out.println("I'm in half century"); 12 | // } else { 13 | // System.out.println("I'm not half century yet"); 14 | // } 15 | switch (age) { 16 | case 30: 17 | System.out.println("Age under 30"); 18 | break; 19 | case 35: 20 | System.out.println("Age under 35"); 21 | break; 22 | case 50: 23 | System.out.println("I'm in half century"); 24 | break; 25 | case 51: 26 | System.out.println("I'm in half century"); 27 | break; 28 | case 52: 29 | System.out.println("I'm in half century"); 30 | break; 31 | default: 32 | System.out.println("Enjoy"); 33 | break; 34 | } 35 | } 36 | } 37 | // breack -> kill flow -------------------------------------------------------------------------------- /Day9/Practice.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Day9/Practice.class -------------------------------------------------------------------------------- /Day9/Practice.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class Practice { 4 | public static void main(String[] args) { 5 | // Practice 1 6 | // int a = 10; 7 | // if (a == 11) { 8 | // System.out.println("Equal"); 9 | // }else{ 10 | // System.out.println("Not Equal"); 11 | // } 12 | 13 | // Practice 2 14 | // byte m1, m2, m3; 15 | // Scanner sc = new Scanner(System.in); 16 | // System.out.println("Enter sub mark 1: "); 17 | // m1 = sc.nextByte(); 18 | // System.out.println("Enter sub mark 2: "); 19 | // m2 = sc.nextByte(); 20 | // System.out.println("Enter sub mark 3: "); 21 | // m3 = sc.nextByte(); 22 | 23 | // float avg = (m1 + m2 + m3) / 3f; 24 | // if (avg >= 40 && m1 >= 33 && m2 >= 33 && m3 >= 33) { 25 | // System.out.println("Passed"); 26 | // } else { 27 | // System.out.println("You failed"); 28 | // } 29 | 30 | // Practice 3 31 | /* 32 | * Scanner sc = new Scanner(System.in); 33 | * float tax = 0; 34 | * float income = sc.nextFloat(); 35 | * if (income < 2.5f) { 36 | * tax = income + tax; 37 | * } 38 | * if (income > 2.5f && income <= 5.0f) { 39 | * tax = tax + 0.05f * (income - 2.5f); 40 | * } else if (income > 5.0f && income <= 10.0f) { 41 | * tax = tax + 0.05f * (income - 2.5f); 42 | * tax = tax + 0.2f * (income - 5f); 43 | * } else if (income > 10.0f) { 44 | * tax = tax + 0.05f * (income - 2.5f); 45 | * tax = tax + 0.2f * (income - 5f); 46 | * tax = tax + 0.3f * (income - 10.0f); 47 | * } 48 | * System.out.println("Total tax is:" + tax); 49 | */ 50 | /* 51 | * Practice 4 52 | * Scanner sc = new Scanner(System.in); 53 | * int day = sc.nextInt(1); 54 | * switch (day) { 55 | * // enhance switch 56 | * case 1 -> System.out.println("Friday"); 57 | * case 2 -> System.out.println("Saterday"); 58 | * case 3 -> System.out.println("Sunday"); 59 | * case 4 -> System.out.println("Monday"); 60 | * case 5 -> System.out.println("Tuesday"); 61 | * case 6 -> System.out.println("Wednesday"); 62 | * case 7 -> System.out.println("Thusday"); 63 | * } 64 | */ 65 | int year = 2022; 66 | if ((year / 4 == 0) && (year % 100 != 0)) { 67 | System.out.println("Leap Year"); 68 | }else{ 69 | System.out.println("Not Leap Year"); 70 | } 71 | 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Project/001 Clock/DigitalClock.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Project/001 Clock/DigitalClock.class -------------------------------------------------------------------------------- /Project/001 Clock/DigitalClock.java: -------------------------------------------------------------------------------- 1 | import javax.swing.*; 2 | import java.awt.*; 3 | import java.text.SimpleDateFormat; 4 | import java.util.Calendar; 5 | 6 | class MyWindow extends JFrame { 7 | 8 | private JLabel heading; 9 | private JLabel clockLabel;; 10 | Calendar calendar; 11 | SimpleDateFormat timeFormat; 12 | String time; 13 | 14 | MyWindow() { 15 | super.setTitle("Clock"); 16 | super.setSize(400, 200); 17 | super.setLocation(900 / 2, 100); 18 | this.createGUI(); 19 | this.setVisible(true); 20 | this.setResizable(false); 21 | setTime(); 22 | } 23 | 24 | // GUI 25 | public void createGUI() { 26 | heading = new JLabel("My Clock"); 27 | clockLabel = new JLabel("Clock"); 28 | clockLabel.setFont(new Font("Poppins", Font.PLAIN, 50)); 29 | clockLabel.setForeground(new Color(0xbbea22)); 30 | clockLabel.setBackground(Color.black); 31 | clockLabel.setOpaque(true); 32 | timeFormat = new SimpleDateFormat("hh:mm:ss a"); 33 | // this.setLayout(new GridLayout(2, 1)); 34 | this.add(heading); 35 | this.add(clockLabel); 36 | } 37 | 38 | public void setTime() { 39 | while (true) { 40 | time = timeFormat.format(Calendar.getInstance().getTime()); 41 | clockLabel.setText(time); 42 | try { 43 | Thread.sleep(1000); 44 | } catch (Exception e) { 45 | e.printStackTrace(); 46 | } 47 | } 48 | } 49 | } 50 | 51 | public class DigitalClock { 52 | 53 | public static void main(String[] args) { 54 | MyWindow w = new MyWindow(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Project/001 Clock/MyWindow.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Project/001 Clock/MyWindow.class -------------------------------------------------------------------------------- /Project/002 GuessingGame/Game.java: -------------------------------------------------------------------------------- 1 | package com; 2 | 3 | import java.util.Random; 4 | import java.util.Scanner; 5 | 6 | class GenNumber { 7 | public int rand; 8 | public int userInput; 9 | public int totalGuess = 0; 10 | 11 | GenNumber() { 12 | Random randNumber = new Random(); 13 | this.rand = randNumber.nextInt(100); 14 | } 15 | 16 | public void getUserInput() { 17 | System.out.print("Guess any number between 0-100: "); 18 | Scanner sc = new Scanner(System.in); 19 | userInput = sc.nextInt(); 20 | } 21 | 22 | boolean Game() { 23 | totalGuess++; 24 | if (userInput == rand) { 25 | System.out.println("You Win! Total guesses: " + totalGuess); 26 | return false; 27 | } else if (userInput < rand) { 28 | System.out.println("Too Low"); 29 | return true; 30 | } else { 31 | System.out.println("Too HIgh"); 32 | return true; 33 | } 34 | } 35 | } 36 | 37 | public class Game { 38 | public static void main(String[] args) { 39 | GenNumber gn = new GenNumber(); 40 | boolean isRunning = true; 41 | while (isRunning) { 42 | gn.getUserInput(); 43 | if (gn.Game() == false) { 44 | break; 45 | } 46 | } 47 | 48 | } 49 | } -------------------------------------------------------------------------------- /Project/002 GuessingGame/GuessingGame.java: -------------------------------------------------------------------------------- 1 | package com; 2 | import java.util.Random; 3 | import java.util.Scanner;; 4 | 5 | class Game { 6 | public int num; 7 | public int inputNum; 8 | public int noOfGuesses = 0; 9 | 10 | public int getNoGuess() { 11 | return noOfGuesses; 12 | } 13 | 14 | public void setNoGuess(int noOfGuesses) { 15 | this.noOfGuesses = noOfGuesses; 16 | } 17 | 18 | Game() { 19 | Random rand = new Random(); 20 | this.num = rand.nextInt(100); 21 | } 22 | 23 | void takeUserInput() { 24 | System.out.println("Guess The Number"); 25 | Scanner sc = new Scanner(System.in); 26 | inputNum = sc.nextInt(); 27 | } 28 | 29 | boolean isCorrectNumber() { 30 | noOfGuesses++; 31 | if (inputNum == num) { 32 | System.out.println("You Win! after trying: " + noOfGuesses); 33 | return true; 34 | } else if (inputNum > num) { 35 | System.out.println("Too High..."); 36 | } else if (inputNum < num) { 37 | System.out.println("Too Low..."); 38 | } 39 | return false; 40 | 41 | } 42 | 43 | } 44 | 45 | public class GuessingGame { 46 | public static void main(String[] args) { 47 | Game g = new Game(); 48 | g.takeUserInput(); 49 | boolean b = false; 50 | while (!b) { 51 | g.isCorrectNumber(); 52 | } 53 | } 54 | } 55 | 56 | // javac -d . GuessingGame.java && java com/GuessingGame 57 | -------------------------------------------------------------------------------- /Project/002 GuessingGame/com/Game.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Project/002 GuessingGame/com/Game.class -------------------------------------------------------------------------------- /Project/002 GuessingGame/com/GenNumber.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devvsakib/java-100days/42cb8f718517e4ab86611bf7273f277771fb36aa/Project/002 GuessingGame/com/GenNumber.class -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 100 Days of Java 2 | 3 | Started learning **Jan 13 2023**...
4 | Spending only 30Min to learn Java every day. After 100days, I will start building 50 Project. 5 | 6 | ### IDE 7 | **Visual Studio Code** 8 | 9 | 10 | I'm using VSCODE. You can use IntelliJ. 11 | --------------------------------------------------------------------------------