OPERATORS: ========== X + Y = 3 HERE: X = 2 Y = 1 ==> 3 == 3 OPERAND: ======== A VALUE ON WHICH WE CAN PERFORM ANY OPERATION ==> VARIABLE OPERATOR ======== ==> A SYMBOL WHICH IT CAN DESCRIBE AN OPERATION EX: +, -, = ETC. EXPRESSION ========== ==> GROUP OF OPERANDS AND OPERATORS ==> AN EXPRESSION IN JAVA NEVER END/TERMINATE WITH SEMI-COLON EX: res = a+b STATEMENT ========= ==> any expression with termination of semi-colon is called as "statement" ==> action of program TYPES OF OPERATORS ================== main classification: based on number of operands: we can classify operators into three types: 1) Unary Operator ==> can always define with single operand 2) Binary Operator ==> can always define with two operands 3) Ternary Operator ==> can always define with three operands ==> Arithmetic operators ==> Assignment operator ==> Compound operator ==> Logical operators ==> Relational operators ==> Conditional Operator ==> Bitwise operators ==> Other operators ex: 97 ==> positive -97 ==> negative ==> Unary minus Unary plus Logical not Bitwise complement addition ==> + 1 + 2 + 3 ========================================== Arithmetic operators ===================== +, -, *, /, %, ++, -- + ==> sum - ==> subtraction * ==> multiplication / ==> division ==> quotient ex: 9/3 ==> 3 rem = 0 % ==> modulo division ==> remainder import java.util.Scanner; class arithmeticOperations{ public static void main(String x[]) { Scanner sco = new Scanner(System.in); int a,b; System.out.println("Enter the values for a and b:"); a = sco.nextInt(); b = sco.nextInt(); System.out.println("All Arithmetic Results are:"); System.out.println("Sum = "+(a+b)); System.out.println("Subtraction = "+(a-b)); System.out.println("Multiplication = "+(a*b)); System.out.println("Quotient = "+(a/b)); System.out.println("Remainder = "+(a%b)); // System.out.println(a**4); } } ============================================= import java.util.Scanner; class arithmeticOperations{ public static void main(String x[]) { Scanner sco = new Scanner(System.in); int a; float b; System.out.println("Enter the values for a and b:"); a = sco.nextInt(); b = sco.nextFloat(); System.out.println("All Arithmetic Results are:"); System.out.println("Sum = "+(a+b)); System.out.println("Subtraction = "+(a-b)); System.out.println("Multiplication = "+(a*b)); System.out.println("Quotient = "+(a/b)); System.out.println("Remainder = "+(a%b)); // System.out.println(a**4); } } ============================================= ++ ==> Increment operator ========================== ==> increase the value by '1' ==> always define with variables. Note: ==== We can't define the increment operator with values directly. Ex: ++10, ++20 etc. ==> Syntax error. ==> divided into two types: 1) Pre-Increment Syntax:++var ==> unary operator 1) first: it can increase the value by '1' 2) second: assignment x = 10 Ex: y = ++x ++x ==> 10 + 1===> x = 11 y = 11 import java.util.Scanner; class arithmeticOperations{ public static void main(String x[]) { Scanner sco = new Scanner(System.in); int a,b; System.out.println("Enter a value for 'a':"); a = sco.nextInt(); // 11 System.out.println("a value before the pre-incement = "+a); b = ++a; // Pre Increment System.out.print("a = "+a+" b = "+b); } } 2) Post-Increment Syntax: var++ Unary Operator 1) First: Assignment 2) Second: Increment by '1' x = 10 Ex: y = x++ y = 10 x = 10 + 1 ==> x = 11 import java.util.Scanner; class arithmeticOperations{ public static void main(String x[]) { Scanner sco = new Scanner(System.in); int a,b; System.out.println("Enter a value for 'a':"); a = sco.nextInt(); // 97 System.out.println("a value before the post-incement = "+a); b = a++; // Post Increment System.out.print("a = "+a+" b = "+b); } } ====================================================== -- ==> Decrement operator ========================== ==> decreasing the value by '1' ==> two types: 1) Pre-decrement Syntax: --var 1) first: decrease the value by '1' 2) second: assignment import java.util.Scanner; class arithmeticOperations{ public static void main(String x[]) { Scanner sco = new Scanner(System.in); int a,b; System.out.println("Enter a value for 'a':"); a = sco.nextInt(); // 97 System.out.println("a value before the pre-decrement = "+a); b = --a; // Pre decrement System.out.print("a = "+a+" b = "+b); } } 2) post decrement Syntax: var-- 1) Assignment 2) decrease the value by '1' import java.util.Scanner; class arithmeticOperations{ public static void main(String x[]) { Scanner sco = new Scanner(System.in); int a,b; System.out.println("Enter a value for 'a':"); a = sco.nextInt(); // 97 System.out.println("a value before the post-decrement = "+a); b = a--; // Post decrement System.out.print("a = "+a+" b = "+b); } }