Symbols:Operators

 
Name Symbol

Uses

Parentheses ()
  • method signature function do_something()
  • if statements ( n =3)
  • loops for (int i = 0; i ,5; i++)
Braces { }
  • class body {   }
  • statement blcok
Brackets [ ]
  • used in arrays
Angles < >
Semi colon ;
  •  at the end of a line, variable
Colon :
  • inheritance

Operator Precedence

Operators Precedence
postfix expr++ expr--
unary ++expr --expr +expr -expr ~ !
division /
multiplicative *
modulus %
additive + -
precedence of  amongst *, /, %
shift << >> >>>
relational < > <= >= instanceof
equality == !=
bitwise AND &
bitwise exclusive OR ^
bitwise inclusive OR |
logical AND &&
logical OR ||
ternary ? :
assignment = += -= *= /= %= &= ^= |= <<= >>= >>>=

 

 
 
Meaning of the operators
    Operator	example		Meaning
    =		i = 2; 		assign integer value to a variable
     		a = "Hello";	assign string to a variable
    +   	         i =  2  +  2 ; 	 i = 4;
    +=  	         i += 3;             i = i + 3;
    -=		i -= 3;		 i = i - 3;
    *=		i *= 4;		 i = i * 4;
    /=		i /= 4;		 i = i / 4;
    %=		i % = 2;	           i = i % 2 ;
    
 
Precedence amongst all
  1. !,++,--
  2. *,/,%
  3. +,-
  4. <,>,<=,>=
  5. = =, !=
  6. &&
  7. ||
  8. =, +=,-=,*=,/=,%=