# Java Operators

&#x20;**Operator**  is a special symbol that tells the compiler to perform specific mathematical or logical Operation. We can divide all the Java operators into the following groups:

* &#x20;Arithmetic Operators&#x20;
* &#x20;Relational Operators&#x20;
* &#x20;Logical Operators&#x20;
* &#x20;Assignment Operators&#x20;
* Ternary or Conditional Operators

#### &#x20;Arithmetic Operators

&#x20;Given table shows the entire Arithmetic operator supported by Java Language. Let's suppose variable A hold 8 and B hold 3.

![](https://106491783-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTW0eWU2biq082hmKEn%2F-LTaOD_z16Z2uoiUkDbL%2F-LTaPEt01ZNDqK-IgBzQ%2Fimage.png?alt=media\&token=36641e2b-6f0c-47d8-805e-8e3ccb1e2cbb)

#### &#x20;Relational Operators

&#x20;Which can be used to check the Condition, it always returns true or false. Let’s suppose variable A hold 8 and B hold 3.

![](https://106491783-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTW0eWU2biq082hmKEn%2F-LTaOD_z16Z2uoiUkDbL%2F-LTaPQ-zLbX5WfG6X9j5%2Fimage.png?alt=media\&token=74dd79ef-8234-4f14-aa3c-66aa814efa2b)

#### &#x20;Logical Operator&#x20;

Which can be used to combine more than one Condition? Suppose you want to combined two conditions A**C, then you need to use Logical Operator like (AC). Here && is Logical Operator.**

![](https://106491783-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTW0eWU2biq082hmKEn%2F-LTaOD_z16Z2uoiUkDbL%2F-LTaPdl7v24fcAISQiWG%2Fimage.png?alt=media\&token=cd4f56a0-f312-4b62-bd14-3fa9eec8864a)

#### &#x20;Assignment operators

&#x20;This can be used to assign a value to a variable. Lets suppose variable A hold 8 and B hold 3.

![](https://106491783-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTW0eWU2biq082hmKEn%2F-LTaOD_z16Z2uoiUkDbL%2F-LTaPyzJbN_kP5v5qpDt%2Fimage.png?alt=media\&token=013d159a-20a8-4a5f-84b2-c9ab588405a9)

#### &#x20;Ternary operator

&#x20;If any operator is used on three operands or variable is known as ternary operator. It can be represented with " ?\


#### : " Syntax&#x20;

#### result = testCondition ? value1 : value2&#x20;

this statement can be read as “If testCondition is true, assign the value of value1 to result; otherwise, assign the value of value2 to result.

#### &#x20;Example:

![](https://106491783-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTW0eWU2biq082hmKEn%2F-LTaOD_z16Z2uoiUkDbL%2F-LTaQLddH61CHZLFsEev%2Fimage.png?alt=media\&token=46a5c472-a70a-4619-9672-71cf4ba51aa7)

