Operators

Java supports a rich set of operators.We have already used several of them, such as =,+,- and *.An Operator is a symbol that tells the computer to perform certain mathematical or logical manipulations.

Primitive Operator:-

Math Operator – eg int x = 6 + 3 ; where “+” is operator and 6,3 is operand

Arithmetic Operator:-

1)Addition:- e.g int Sum = 50 + 60 ; where “+” is additional operator.

2)Subtraction:- e.g int sub = 100 10 ; where “” is additional operator.

3)Multiplication:- e.g int a =100 * 2 ; where “*” is additional operator.

4)Division:- e.g int b = 100 / 5 ; where “/” is additional operator.

5)Modulo:-It is remainder of two constants.e.g int b = 6 % 3  //b=2 ; where “%” is additional operator.

Increment Operator:- This operator increase the value by 1.e.g x = x+1 or ++x “++” is increment oper.  Decrement operator (–) decreases the value by 1 e.g x = x-1 or ” – -x“.

Prefix :-Increment or decrement the variable’s value & use the new value in expression is Prefix. e.g  int x = 34 ; int y = ++x ; // y = 35 . The value x is 1st incremented to 35 and then assign to y.

Postfix :- The variable value is 1st used in expression & then incremented or decremented. e.g int x = 34 ; int y = x++ ; // y = 34 .The value of x is assign to y first and then it is incremented.

More Operators