# Java Operator Precedence and Associativity Table Java Operator Precedence and Associativity Table

# Java Operator Precedence and Associativity Table

Java Operator: A java operator can be used in mathematical operations performed.

it is performed by java operands mathematical symbols like (+),(-),(*),(/), etc.

the operator can be used in every programming language. the operator has defined operations perform in operands.

# 1. Arithmetic Operator2. Relational Operator3. Logical Operator 4. Assignment operator5. Bitwise Operator6. Increment operator7. Decrement Operator8. Conditional Operator

## Arithmetic operator in Java

Arithmetic Operator: A arithmetic operation is a used mathematical operation performed.

It is many operations performed like addition, subtraction, multiplication, and division.

Example of Arithmetic operator

Here a is operands value (+) Addition is operator and b is operands. It can be used for additional operations performed.

Subtraction: a-b or 20-10=10

Here a is operands value (-) Subtraction sign is operator and b is operands. It can be used as Subtraction operations performed.

Multiplication: a*b or 10*10=100

Here a is operands value (*) Multiplication sign is operator and b is operands. It can be used for Multiplication operations performed.

Division: a/b or 10/5=2

Here a is operands value (/) Division sign operator and b is operands. It can be used for Division operations performed.

Modules: a%b or 10%3=1

Here a is operands value (%) Modules sign operator and b is operands. It can be used to Modules operations performed.

### Java Arithmetic Operator Table

 Sign Operation Example (+) Addition (x+y) (-) Subtraction (x-y) (/) Multiplication (x*y) (*) Division (x/y) (%) Modules (x%y)

### Arithmetic Operator in Java?

 class codeswithbaby{public static void main(String[] args(){int a=35int b=6;System. out.println("Addition:"+(a+b));System. out.println("Subtraction:"+(a-b));System. out.println("Multiplication:"+(a*b));System. out.println("Division:"+(a/b));System. out.println("Modulus:"+(a%b));}} *****OUTPUT*****Addition:41Subtraction:29Multiplication:210Division:5.8333333Modulus:5

## Relational Operator in Java

Relational Operator: A Java Relational operator has used the comparison of the two operands. It can be using equal operands and condition checks in this operator. The relational operator is the very most useful operator.

Java Relational Operator Table

 Sign Operation Example (==) Equal (a=b) (!=) Not Equal To (!a=b) (>) Greater Than (a>b) (<) Less Than (a=) Greater Than or Equal (a>=b) (<=) Less Than or Equal (a<=b)

### Relational Operator in Java

 class codeswithbaby{public static void main(String[] args(){int a=10;int b=10;if(a==b){System.out.println("value of a and b are equal");}if(a!=100){System.out.println("value not equal to");}if(a>5){System.out.println("value a is grater than 5");}if(a<50){System.out.println("value a is less than 50");}if(a>=10){System.out.println("value a is grater than or equal to 10");}if(a<=10){System.out.println("value a is less than or equal to 10");}}*****OUTPUT*****value of a and b are equalvalue not equal tovalue a is greater than 5value a is less than 50value a is greater than or equal to 10value a is less than or equal to 10

## Assignment Operator Table

 Sign Operation Example (=) a=b (a=b) (+=) a+=b (a=a+b) (-=) a-=b (a=a-b) (*=) a*=b (a=a*b) (/=) a/=b (a=a/b) (%=) a%=b (a=a%b)

### Assignment Operator in Java?

 class codeswithbaby{public static void main(String[] args(){int a=10,b=5;a+=b;System.out.println("Assignment Addition:"+a);int a1=10,b1=5;a1-=b1;System.out.println("Assignment Subtraction:"+a1);int a2=10,b2=5;a2*=b2;System.out.println("Assignment multiplication:"+a2);int a3=10,b3=5;a3/=b3;System.out.println("Assignment Division:"+a3);int a4=10,b4=5;a4%=b4;System.out.println("Assignment Division:"+a4);}}*****OUTPUT*****Assignment Addition:15Assignment Subtraction:5Assignment Multiplication:50Assignment Division:2Assignment Moduls:1

## Increment Operator in  Java

Increment Operators: Increment Operators are useful operators generally used.like++x and x++ means x=x+1.

pre-increment first adds one to the operand and then the result is assigned to the variable on the left.

post-increment first assigns the value to the variable on the left and then increments the operand.

### Increment Operator in Java?

 class codeswithbaby{public static void main(String[] args(){int a=5;int b=10;System.out.println("pre-increment operator:+(++a));System.out.println("post-increment operator:+(b+1));}}*****OUTPUT*****pre-increment operator:6post-increment operator:11

## Decrement Operator in  Java

Java Decrement: A Decrement Operator used the decrease the value. like --x and x--.

Pre-decrement first less one to the operands and then the result is assigned to the variable on the left.

Post-decrement first assigns the value to the variables on the left and then decrements the operands.

### Decrement Operator in Java?

 class codeswithbaby{public static void main(String[] args(){int a=5;int b=10;System.out.println("pre-decrement operator:+(--a));System.out.println("post-decrement operator:+(b-1));}*****OUTPUT*****pre-decrement operator:4post-decrement operator:9

## Bitwise Operator in  Java

Java Bitwise Operator: A Bitwise operator is an operation performed on the data bit level. the bitwise operator is also shifted bit right to left.

Note: Bitwise operators are not allowed to float and double.

### Bitwise Operator Table

 Sign Operation Example (&) Bitwise AND (a&b) (|) Bitwise OR (a|b) (<<) Bitwise LEFT (a<>) Bitwise RIGHT (a>>b)

## Java Unary Operator

Unary Operator: A Java unary operators require only one operand. Unary operators are used for performing various operations in a java programming language.

### Java Unary Operator

 public class codeswithbaby{  public static void main(String args[]){  int a=10;  int b=10;  System.out.println(a++ + ++a); System.out.println(b++ + b++);   }}*****OUTPUT*****  2221

### Java Unary Operator

 public class codeswithbaby{  public static void main(String args[]){  int x=10;  System.out.println(x++);  System.out.println(++x);System.out.println(x--);  System.out.println(--x);}}  *****OUTPUT*****10121210