javac ==> compilation Syntax: javac filename.java java ==> execution syntax: java filename.java Q: Is it possible to execute the java program without the compilation? ====================================================================== from Java11 ==> Standard no compilation is needed. before java-11: java-8, java9, java10 etc. we must compile and then execute ===================================================== Variables can be initialized in two ways: 1) Compile time Initialization datatype name = value; datatype name; name = value; 2) Run time Initialization we need a package "util" Scanner class (inbuilt) ==> import Syntax: import java.util.Scanner; We should create an object for the Scanner class to access the input methods to take the data for variable in run time. (main() method) Syntax: Scanner object-name = new Scanner(System.in); IO Streams In Java: =================== Input and Output Streams Stream ==> byte code/group of data have one pre-defined package java.io three streams: 1) System.in: this is an inbuilt input stream use to read values while running of the program 2) System.out: println() print() printf() we can write anything of the screen/console. 3) System.err: println() print() printf() to write about error description ==================================== Taking of Integral Values in Run Time: ===================================== ==> to take integral values, we have four different built-in methods in Scanner class: 1) nextByte() ==> we can use to read a byte value scanner-object.nextByte(); 2) nextShort() 3) nextInt() 4) nextLong() import java.io.*; // optional import java.util.Scanner; // mandatory class IoOperations{ public static void main(String s1[]) { Scanner sco = new Scanner(System.in); byte b; short s; int i; long l; System.out.println("Enter all integral values:"); b = sco.nextByte(); s = sco.nextShort(); i = sco.nextInt(); l = sco.nextLong(); System.out.println(b); System.out.println(s); System.out.println(i); System.out.println(l); } } Ravikumar camel case: ravikumar javaprogramminglanguage camel case: javaProgrammingLanguage ================================================ Taking Floating-point data in run time: ======================================= nextFloat() nextDouble() import java.io.*; // optional import java.util.Scanner; // mandatory class IoOperations{ public static void main(String s1[]) { Scanner sco = new Scanner(System.in); float f1,f2; double d1,d2; f1 = 1.223f; // float d1 = 0.0012; // double System.out.println("Enter a float value:"); f2 = sco.nextFloat(); System.out.println("Enter a double value:"); d2 = sco.nextDouble(); System.out.println(f1); System.out.println(f2); System.out.println(d1); System.out.println(d2); } } ============================================= Reading/taking of Boolean value in the run time: =============================================== nextBoolean() import java.io.*; // optional import java.util.Scanner; // mandatory class IoOperations{ public static void main(String s1[]) { Scanner sco = new Scanner(System.in); boolean b; System.out.println("Enter a boolean value:"); b = sco.nextBoolean(); System.out.println(b); } } ================================= Assignment: =============== 1) WAP to accept the character in the run time and print that character on the screen.