Operator Kinds of Operator Precedence of Operator Type Casting
Decide the semantics of expression Meaning of operator given in language system Operator
Kinds of Operator Arithmetic Op. : + - * / % Relational Op. : > >= >= < <= == != Logical Op. : && || ! Inc/Dec Op. : Bit Op. : & | ^ ~ > >>> Operators of Java Conditional Op. : ?: Conditional Op. : ?: Assign Op. : = += -= *= /= %= &= ^= |= >>= >>= Casting Op. : (Data Type) Array Op. : [] Method Op. : (). instanceof Op. : instanceof
Operator for arithmetic operation Single term operator : +, - Binary term operator : +, -, *, /, % [ArithmeticOperators.java] Arithmetic Operator x = -5 ; x = -(-5) ; x = -(3-5) ; x = -5 ; x = -(-5) ; x = -(3-5) ;
Real type operation Floating point discription and operation: IEEE754 Standard underflow, overflow Infinitive arithmetic java.lang.Float, java.lang.Double, POSITIVE_INFINITY, NEGATIVE_INFINITY constant NaN(Not a Number) Arithmetic Operator
Compare two value Result : true or false Expression include relational operator for, while,... Operator , , , , , precedence [RelationalOperators.java] Relational Operator a > b + c ===>a > (b + c) b == x b == (x < y)
Conditional Logical Relationship of two operands Operator !, &&, || [LogicalOperators.java] Conditional Operator a < b && b < c 1 2 3
Operator ++, -- Prefix operator Postfix operator Cannot use at expression, only at variable Cannot apply at real type [IncDecOperators.java] Increment & Decrement Operator n = 1; x = ++n; // x=2, n=2 n = 1; x = ++n; // x=2, n=2 n = 1; x = n++; // x=1, n=2 n = 1; x = n++; // x=1, n=2 (a + b)++ // error
Operator &, |, >, >>>, ^, ~ Operand should be integer type Precedence Bitwise Operator Operator Precedence Operator Precedence ~ > >>> & ^ | (H) (L)
Bitwise AND & = To extract the special area in variable by masking that area Bit OR | = Exclusive AND ^ = 1’s Complement ~ = [BitOperators.java] Bitwise Operator
Bitwise Shift Operator Shift lefe(<<) Shift right(>>) Unsigned shift right(>>>) Give this operator because Java does not support unsigned integer. [ShiftOperators.java] Bitwise Operator x << y = x * 2 y x >> y = x / 2 y
Operator Expr1 ? Expr2 : Expr3 (3 Terms Operator) [ConditionalOperator.java] [PrintTenItem.java] The Conditional Operator m = a > b ? (c > a ? c : a) : (c > b ? c : b) ; max = x > y ? x : y ; if (x > y) max = x; else max = y; if (x > y) max = x; else max = y;
Operator Arithmetic operator : + - * / % Bitwise operator : & | ^ > >>> [AssignmentOperators.java] Assignment Operators Expr 1 = Expr 1 op Expr2 Expr 1 op= Expr 2 x = x * y + 1; x *= y + 1; x = x * (y+1) sum = sum + i ; sum += i ;
Operator Precedence Operator Association Precedence () []. ! ~ (Data Type) * / % + - > >>> >= instance == != & ^ | && || ? : = += -= *= /= %= &= ^= |= >= >>>= Left Assoc. (High) Left Assoc. Left Assoc. (Low)