---
title: "How many types of operator used in Java?"  
description: "How many types of operator used in Java?"  
author: "Nitin Kushwaha"  
published: 2019-07-11  
updated: 2025-02-24  
canonical: https://www.mindstick.com/forum/55160/how-many-types-of-operator-used-in-java  
category: "java"  
tags: ["we can use various types of operators in java."]  
reading_time: 3 minutes  

---

# How many types of operator used in Java?

**[Operators](https://www.mindstick.com/articles/716/php-operators) in java:-** **Different types of operators in java which are given below:**

- Unary Operator,
- Arithmetic Operator,
- Shift Operator,
- [Relational](https://www.mindstick.com/blog/10885/equality-relational-and-conditional-operators) Operator,
- [Bitwise Operator](https://answers.mindstick.com/qa/104698/what-is-a-bitwise-operator),
- [Logical](https://www.mindstick.com/forum/33581/what-is-inserted-deleted-logical-table-in-sql-server) Operator,
- [Ternary Operator](https://www.mindstick.com/forum/12944/ternary-operator-in-razor-using-a-model) and
- [Assignment](https://www.mindstick.com/articles/126300/apa-citation-style-get-to-know-about-it-for-your-next-assignment) Operator.

**Unary Operator:-** It is used to [increment](https://www.mindstick.com/forum/173/auto-increment-id) or decrement a value by one. **i++, i-- (Postfix)** **++i, --i (Prefix)** Postfix-first print then increment. Prefix-first increment then print. **Example**

```
 class OperatorExample{
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
10
12
12
10.
```

**Arithmetic Operator:-** It can be used to perform mathematical [operations](https://www.mindstick.com/blog/304985/how-does-devops-bridge-the-gap-between-development-and-operations-teams-like-git) such as addition, subtraction, multiplication, and division (+,-,*,/). **Example**

```
class student
{
public static void main(String args[])
{
int a=22;
int b=10;
System.out.println(a+b);
System.out.println(a-b);
System.out.println(a*b);
System.out.println(a/b);
}
}
```

```
Output
32
12
220
2.2.
```

**If we use third [variables](https://www.mindstick.com/articles/715/php-variables) to store the result are:-**

```
class student { public static void main(String args[]) { int m=22; int n=10; int c; c=m+n; System.out.println(c); c=m-n; System.out.println(c); c=m*n; System.out.println(c); c=m/n; System.out.println(c); } }
```

```
Output-
32
12
220
1.2 .
```

\

## Replies

### Reply by Khushi Singh

**Java has eight major [operator](https://www.mindstick.com/blog/144/union-intersection-and-except-operator-in-sql-server) types for processing variable and value data.**

- The arithmetic operators do basic math by adding, subtracting, multiplying, dividing, and finding the remainder in calculations. Java programmers use these operators to handle mathematical processes securely.\
- Relational operators test how values compare to each other. These operators establish whether values match, differ, stand above or below other values, and deliver an outcome as true or false.\
- You use Logical Operators to handle logical processing tasks with boolean information. The AND operator shows true status when both evaluation results come out positive yet the OR operator produces true if any evaluation returns true results. The NOT operator negates the value of a boolean expression.\
- Bitwise Operators take action on each single number bit to modify its behavior. Basic bit operations like AND, OR, and XOR plus shift to the left and right form an important part of programming at the lowest level.\
- The assignment operator sets numeric values into specific programming locations. Beyond the simple assignment operator (=) there are shortcut operators +=, -=, *=, /= and %= that perform both assignments and arithmetic operations to shorten coding.\
- Unary Operators work directly with a single element. Operators ++ and -- change values by plus and minus one while + and - work in isolation.\
- The Ternary Operator serves as a shorter method to write if-else statements. The feature lets you assign values through conditions in a smaller space that improves both code appearance and performance.\
- The instanceof Operator verifies if an object holds membership in its designated class or inherits from its subclasses. Before running an operation on an object this operator checks at runtime that the object matches the expected type.


---

Original Source: https://www.mindstick.com/forum/55160/how-many-types-of-operator-used-in-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
