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

SOFTWARE

Unit 2: Foundations of Ownership, Security Related Concepts in Blockchain

e-com sem-3

Unit-1 Foundations of Software Systems and Blockchain

6)what are the various service of internet and protocols ICT-unit-1

digital marketing ppt-u1

Unit-V: Image Manipulations, Audio and Video & Introduction to JavaScript

Unit-III: Cascading Style Sheets (CSS) - HTML

Unit-II: HTML Coding Standards & Elements

1) Information and Communication Technology ICT-unit-1