Java Operators

Java Operators

 In Java, operators are symbols that perform operations on variables and values. They can be classified into different types based on the operation they perform. Below is a summary of Java operators:

1. Arithmetic Operators

These operators are used to perform basic mathematical operations.
- `+` (Addition)
- `-` (Subtraction)
- `*` (Multiplication)
- `/` (Division)
- `%` (Modulus)

2. Unary Operators

Unary operators perform operations on a single operand.
- `+` (Unary plus)
- `-` (Unary minus)
- `++` (Increment)
- `--` (Decrement)
- `!` (Logical NOT)

3. Relational (Comparison) Operators

These operators compare two values and return a boolean result (`true` or `false`).
- `==` (Equal to)
- `!=` (Not equal to)
- `>` (Greater than)
- `<` (Less than)
- `>=` (Greater than or equal to)
- `<=` (Less than or equal to)

4. Logical Operators

Logical operators are used to combine conditional statements.
- `&&` (Logical AND)
- `||` (Logical OR)
- `!` (Logical NOT)

5. Bitwise Operators

These operators are used to perform bit-level operations.
- `&` (Bitwise AND)
- `|` (Bitwise OR)
- `^` (Bitwise XOR)
- `~` (Bitwise NOT)
- `<<` (Left shift)
- `>>` (Right shift)
- `>>>` (Unsigned right shift)

6. Assignment Operators

Assignment operators are used to assign values to variables.
- `=` (Simple assignment)
- `+=` (Add and assign)
- `-=` (Subtract and assign)
- `*=` (Multiply and assign)
- `/=` (Divide and assign)
- `%=` (Modulus and assign)

7. Ternary Operator

The ternary operator is a shorthand for an `if-else` statement.
- `? :` (Condition)  


  Syntax: `condition ? value_if_true : value_if_false`

8. Instance of Operator

This operator is used to check if an object is an instance of a particular class or subclass.
- `instanceof`

9. Type Cast Operator

Used to explicitly convert a value from one data type to another.
- `(type)`

These are the primary operators in Java. They enable a wide range of functionality from simple calculations to complex logic.

Comments

Popular posts from this blog

digital marketing ppt-u1

SOFTWARE

cn lab

Computer Operations and Performing - D L Unit-1-1

DBMS Degree Lab Records

DS-Record-mca-04) write a program for evaluating a given postfix expression using stack.

Java unit-1 history , C++ vs Java , java environment

Access the Internet to Browse Infromation & E-Mail Operation- D L Unit-2-1

OAT-Record-01) Visiting card

java program structure,java Tokens, keywords,