# Java Operators

# Overview

Java operators are symbols that operate on operands to compute result of an expression. Operator have precedence. Operators with higher precedence are evaluated before in the expression. There are many Java operators that we can use in the programs.

They can broadly classified into:

- Unary operators
- Arithmetic operators
- Relational Operators
- Logical Operators
- Comparison operators
- Bitwise Operators
- Ternary Operators
- Assignment Operators

## Operator Precedence

Operators generally do have precedence rules to make it clear the order of operations to calculate an expression. For example, the multiplication operator (*) takes precedence over addition operator (+)

## Associativity

Operator associativity is the rule to apply among the operators of same precedence levels and when not grouped with brackets in the expression. For example, In Java multiplication operator * and the division operator / have the same precedence. The Associativity rule for these operators in **left to right**. We can override these rules by using brackets in the expression. We will discuss this later with detailed examples.

### Example

double result = 30 / 5 * 3;

System.out.println(result);

Output is : 18.0

/ operator took precedence over the * operator. So the result is 18.0 and NOT 2.0

—

## Java Tutorials

Java Tutorial on this website:

https://www.testingdocs.com/java-tutorial/

For more information on Java, visit the official website :