├── .gitignore ├── .vscode └── launch.json ├── Arrays ├── ComArray.java ├── ComArraym.java ├── ConsoleExam.java ├── IterateArray.java ├── Typcast.java └── enhanced_for_loop.java ├── README.md ├── StudentImpl.java ├── basics ├── ArithmeticOp.java ├── ArmstrongImpl.java ├── FactImpl.java ├── HelloWorld.java ├── InputMethods.java ├── NarrowCastExample.java ├── Primitive.java ├── Strings.java ├── StudentImpl.java ├── TypCast.java ├── armstrongimpl.java ├── controlstatements │ ├── EnhancedFor.java │ ├── Ifstmt.java │ ├── NestedIf.java │ ├── SwitchCase.java │ └── WhileExam.java ├── datatype │ ├── Datatype.java │ ├── NarrowCastExample.java │ └── TypeConv.java ├── factimpl.java └── variables │ ├── Cricketer.java │ ├── CricketerImpl.java │ ├── InstanceVar.java │ └── StaticVar.java └── notes ├── Arrays.pptx ├── Control statements.pptx ├── JP COURSE FILE-converted.pdf ├── Java Type Casting.pptx ├── intro-2.pptx ├── java intro.pptx └── operators,expressions,control stmts.pptx /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | replay_pid* 25 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "type": "java", 5 | "name": "WhileExam", 6 | "request": "launch", 7 | "mainClass": "basics.controlstatements.WhileExam", 8 | "projectName": "OOP-using-Java_b9476530" 9 | }, 10 | { 11 | "type": "java", 12 | "name": "SwitchCase", 13 | "request": "launch", 14 | "mainClass": "basics.controlstatements.SwitchCase", 15 | "projectName": "OOP-using-Java_b9476530" 16 | }, 17 | { 18 | "type": "java", 19 | "name": "Datatype", 20 | "request": "launch", 21 | "mainClass": "basics.datatype.Datatype", 22 | "projectName": "OOP-using-Java_b9476530" 23 | }, 24 | { 25 | "type": "java", 26 | "name": "CricketerImpl", 27 | "request": "launch", 28 | "mainClass": "basics.variables.CricketerImpl", 29 | "projectName": "OOP-using-Java_b9476530" 30 | }, 31 | { 32 | "type": "java", 33 | "name": "InstanceVar", 34 | "request": "launch", 35 | "mainClass": "basics.variables.InstanceVar", 36 | "projectName": "OOP-using-Java_b9476530" 37 | }, 38 | { 39 | "type": "java", 40 | "name": "NestedIf", 41 | "request": "launch", 42 | "mainClass": "basics.controlstatements.NestedIf", 43 | "projectName": "OOP-using-Java_b9476530" 44 | }, 45 | { 46 | "type": "java", 47 | "name": "Ifstmt", 48 | "request": "launch", 49 | "mainClass": "basics.controlstatements.Ifstmt", 50 | "projectName": "OOP-using-Java_b9476530" 51 | }, 52 | { 53 | "type": "java", 54 | "name": "NarrowCastExample", 55 | "request": "launch", 56 | "mainClass": "basics.NarrowCastExample", 57 | "projectName": "OOP-using-Java_b9476530" 58 | }, 59 | { 60 | "type": "java", 61 | "name": "TypeConv", 62 | "request": "launch", 63 | "mainClass": "basics.TypeConv", 64 | "projectName": "OOP-using-Java_b9476530" 65 | }, 66 | { 67 | "type": "java", 68 | "name": "ArmstrongImpl", 69 | "request": "launch", 70 | "mainClass": "basics.ArmstrongImpl", 71 | "projectName": "OOP-using-Java_b9476530" 72 | }, 73 | { 74 | "type": "java", 75 | "name": "FactImpl", 76 | "request": "launch", 77 | "mainClass": "basics.FactImpl", 78 | "projectName": "OOP-using-Java_b9476530" 79 | }, 80 | { 81 | "type": "java", 82 | "name": "StudentImpl", 83 | "request": "launch", 84 | "mainClass": "basics.StudentImpl", 85 | "projectName": "OOP-using-Java_b9476530" 86 | }, 87 | { 88 | "type": "java", 89 | "name": "ArithmeticOp", 90 | "request": "launch", 91 | "mainClass": "basics.ArithmeticOp", 92 | "projectName": "OOP-using-Java_b9476530" 93 | }, 94 | { 95 | "name": "gcc.exe - Build and debug active file", 96 | "type": "cppdbg", 97 | "request": "launch", 98 | "program": "${fileDirname}\\${fileBasenameNoExtension}.exe", 99 | "args": [], 100 | "stopAtEntry": false, 101 | "cwd": "${fileDirname}", 102 | "environment": [], 103 | "externalConsole": true, 104 | "MIMode": "gdb", 105 | "miDebuggerPath": "E:\\CodeBlocks\\MinGW\\bin\\gdb.exe", 106 | "setupCommands": [ 107 | { 108 | "description": "Enable pretty-printing for gdb", 109 | "text": "-enable-pretty-printing", 110 | "ignoreFailures": true 111 | } 112 | ], 113 | "preLaunchTask": "C/C++: gcc.exe build active file" 114 | }, 115 | { 116 | "name": "gcc build & run active file", 117 | "type": "cppdbg", 118 | "request": "launch", 119 | "program": "${fileDirname}\\${fileBasenameNoExtension}.exe", 120 | "args": [], 121 | "stopAtEntry": false, 122 | "cwd": "${fileDirname}", 123 | "environment": [], 124 | "externalConsole": false, 125 | "MIMode": "gdb", 126 | "miDebuggerPath": "E:\\CodeBlocks\\MinGW\\bin\\gdb.exe", 127 | "setupCommands": [ 128 | { 129 | "description": "Enable pretty-printing for gdb", 130 | "text": "-enable-pretty-printing", 131 | "ignoreFailures": true 132 | } 133 | ], 134 | "preLaunchTask": "gcc build & run active file" 135 | } 136 | ] 137 | } -------------------------------------------------------------------------------- /Arrays/ComArray.java: -------------------------------------------------------------------------------- 1 | public class ComArray{ 2 | int[] arr3={4,7,3,9,2}; 3 | public static void main(String[] args) { 4 | /*common array element*/ 5 | int[] arr1={4,7,3,9,2}; 6 | int[] arr2={3,2,12,9,40,32,4}; 7 | for(int i=0;iarr[i]) 9 | min=arr[i]; 10 | System.out.println(min); 11 | 12 | } 13 | public static void main(String[] args){ 14 | int a[]={33,3,4,5}; 15 | min(a); 16 | } 17 | } -------------------------------------------------------------------------------- /Arrays/ConsoleExam.java: -------------------------------------------------------------------------------- 1 | import java.io.Console; 2 | /** 3 | System.console() returns null if your application is not run in a terminal (though you can handle this in your application 4 | secure password entry (hard to do cross-platform) 5 | synchronisation (multiple threads can prompt for input and Console will queue them up nicely, whereas if you used System.in/out then all of the prompts would appear simultaneously). 6 | 7 | */ 8 | class ConsoleExam{ 9 | public static void main(String[] args) { 10 | System.out.println("using console"); 11 | Console con=System.console(); 12 | if(con!=null){ 13 | con.printf("enter your name"); 14 | String name=con.readLine(); 15 | con.printf("Hello,%s!%n",name); 16 | }else{ 17 | System.out.println("console not available"); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Arrays/IterateArray.java: -------------------------------------------------------------------------------- 1 | class IterateArray{ 2 | public static void main(String[] ar){ 3 | int[] arr={1,2,4,5,6,7}; 4 | ComArray co=new ComArray(); 5 | for(int l:co.arr3){ 6 | System.out.println(l); 7 | } 8 | 9 | ComArray.main(null); 10 | System.out.println("elements are"); 11 | //array.length property tells the total elements in array 12 | for(int i=0;i=18){ 9 | System.out.println("You are allowed to vote"); 10 | } 11 | else{ 12 | System.out.println("You are not eligible"); 13 | } 14 | sc.close(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /basics/controlstatements/NestedIf.java: -------------------------------------------------------------------------------- 1 | package basics.controlstatements; 2 | 3 | public class NestedIf { 4 | public static void main(String[] args){ 5 | java.util.Scanner sc=new java.util.Scanner(System.in); 6 | System.out.println("enter your favorite iconic character:"); 7 | String act=sc.nextLine(); 8 | if(act.equals("Iron Man")){ 9 | System.out.println("Great choice"); 10 | System.out.println("enter"+act+"real name"); 11 | String reall=sc.nextLine(); 12 | if(reall.equalsIgnoreCase("tony stark")){ 13 | System.out.println("Cool actor"); 14 | } 15 | }else{ 16 | System.out.println(act); 17 | } 18 | sc.close(); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /basics/controlstatements/SwitchCase.java: -------------------------------------------------------------------------------- 1 | package basics.controlstatements; 2 | import java.util.*; 3 | public class SwitchCase { 4 | public static void main(String[] args) { 5 | int a=4,b=2; 6 | Scanner sc=new Scanner(System.in); 7 | System.out.println("******"); 8 | System.out.println("*ARITHMETIC OPERATIONS***"); 9 | System.out.println("1. Add"); 10 | System.out.println("2. Sub"); 11 | System.out.println("3. Mul"); 12 | System.out.println("4. Div"); 13 | System.out.println("enter your choice"); 14 | int ch=sc.nextInt(); 15 | switch(ch){ 16 | case 1-> System.out.println("addition result is"+(a+b)); 17 | case 2-> System.out.println("subtraction result is"+(a-b)); 18 | case 3-> System.out.println("multiplication result is"+(a*b)); 19 | case 4-> System.out.println("division result is"+(a/b)); 20 | default -> System.out.println("give proper option"); 21 | } 22 | sc.close(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /basics/controlstatements/WhileExam.java: -------------------------------------------------------------------------------- 1 | package basics.controlstatements; 2 | import java.util.*; 3 | /** 4 | * Java program to accept input and store in arrays 5 | */ 6 | public class WhileExam { 7 | public static void main(String[] p){ 8 | Scanner sc=new Scanner(System.in); 9 | int i=0; 10 | System.out.println("enter the limit"); 11 | int n=sc.nextInt(); 12 | System.out.println("enter the marks"); 13 | int marks[]=new int[n]; 14 | while(i