0% found this document useful (0 votes)
2 views2 pages

Java Operatos

In Java, operators are symbols or keywords that perform operations on variables and values, categorized into several types including arithmetic, relational, logical, assignment, unary, bitwise, ternary, instanceof, and type cast operators. Each category serves specific functions such as mathematical calculations, comparisons, logical operations, and value assignments. Understanding these operators is essential for programming logic and expressions in Java.

Uploaded by

naryugam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Java Operatos

In Java, operators are symbols or keywords that perform operations on variables and values, categorized into several types including arithmetic, relational, logical, assignment, unary, bitwise, ternary, instanceof, and type cast operators. Each category serves specific functions such as mathematical calculations, comparisons, logical operations, and value assignments. Understanding these operators is essential for programming logic and expressions in Java.

Uploaded by

naryugam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Operators in Java

In Java, operators are special symbols or keywords used to perform operations on variables and values.
They are categorized based on the type of operation they perform.

1. Arithmetic Operators These operators perform basic mathematical operations:

• + (Addition)
• - (Subtraction)
• * (Multiplication)
• / (Division)
• % (Modulus)

2. Relational (Comparison) Operators These operators compare two values:

• == (Equal to)
• != (Not equal to)
• > (Greater than)
• < (Less than)
• >= (Greater than or equal to)
• <= (Less than or equal to)

3. Logical Operators Used to perform logical operations:

• && (Logical AND)


• || (Logical OR)
• ! (Logical NOT)

4. Assignment Operators Used to assign values to variables:

• = (Assign)
• += , -= , *= , /= , %= (Compound assignment operators)

5. Unary Operators Operate on a single operand:

• + (Unary plus)
• - (Unary minus)
• ++ (Increment)
• -- (Decrement)
• ! (Logical NOT)

6. Bitwise Operators Perform bit-level operations:

• & (Bitwise AND)


• | (Bitwise OR)
• ^ (Bitwise XOR)
• ~ (Bitwise complement)

1
• << (Left shift)
• >> (Right shift)
• >>> (Unsigned right shift)

7. Ternary Operator A shorthand for if-else :

• ? : (Condition ? value_if_true : value_if_false)

8. instanceof Operator Used to test whether an object is an instance of a specific class or subclass:

• instanceof

9. Type Cast Operator Used to explicitly convert a value from one type to another:

• (type)

Example Code:

int a = 10, b = 20;


int max = (a > b) ? a : b; // Ternary Operator
System.out.println("Maximum: " + max);

These operators are the foundation of programming logic and expressions in Java.

You might also like