Operator Precendence
(12)
Post-unary operators: expression++, expression–
Pre-unary operators: ++expression, –expression
Other unary operators : +, -, !
Multiplication/Division/Modulus : *, /, %
Addition/Subtraction: +, -
Shift operators : <<, >>, >>>
Relational operators: <, >, <=, >=, instanceof
Equal to/not equal to: ==, !=
Logical operators: &, ^, |
Short-circuit logical operators : &&, ||
Ternary operators : boolean expression ? e1 : e2
Assignment operators : =, +=, -=, *=, /=, %=, &=, ^=, !=, <<=, >>=, >>>=
Numeric Promotion
(4)
Unary Operators
(5)
Compound Assignment Operators
long x = 10;
int y = 5;
y = y * x; –> does not compile
y *= x; –> compiles
Equality Operators
(3)
Ternary Operator
(2)
Switch Statement
(6)
Data types supported by switch statements include the following: (no long or boolean)
The for Statement
(3)
for(initialization; booleanExpression; updateStatement) {
// Body
}
Curly braces required for block of multiple statements, optional for single statement
Infinite Loop:
for( ; ; ) {System.out.println(“Hello World”); }
foreach:
for(datatype instance : collection) {
//body
}Labels and break
(3)
optionalLabel: while(booleanExpression) {
// Body
// Somewhere in loop break optionalLabel;
}
optionalLabel: while(booleanExpression) {
// Body
// Somewhere in loop continue optionalLabel;}
While the break statement transfers control to the enclosing statement, the continue statement transfers control to the boolean expression that determines if the loop should continue