Java Operators and Types

Java operators are used to perform action with operants like variables, values, constants.



Java Operator types

Java operators are classified into seven types as shown below

  • Arithmetic Operator
  • Relational Operator
  • Logical Operator
  • Assignment Operator
  • Unary Operator
  • Ternary Operator
  • Bitwise Operator


Java Operators Precedence

if an expression has more than one operator, then expression will evaluate based on operator precedence from higher to lower as shown below.

Operator TypeOperator NameOperator
Unary OperatorPostfixx++ x–
Unary OperatorPrefix++x –x +x -x ~ !
Arithmetic OperatorMultiplicative* / %
Arithmetic OperatorAdditive+ –
Shift OperatorShift<< >> >>>
Relational OperatorComparison< > <= >= instanceof
Relational OperatorEquality== !=
Bitwise OperatorAND&
Bitwise Operator OR|
Bitwise OperatorXOR^
Logical OperatorAND&&
Logical OperatorOR||
Ternary OperatorTernary? :
Assignment OperatorAssignment= += -= *= /= %= &= ^= |= <<= >>= >>>=



Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *