DEV Community

Kavitha
Kavitha

Posted on

Operators in Java

*Operators *
Operators are symbols that perform operations on variables and values.

Arithmetic Operators

Used for mathematical calculations such as addition, subtraction, multiplication, and division.

Example:

int result = 10 + 5;

Enter fullscreen mode Exit fullscreen mode

Relational Operators
Used to compare two values and return a boolean result.
Example:

System.out.println(a > b);

Enter fullscreen mode Exit fullscreen mode

Logical Operators
Used to combine or reverse boolean conditions.
Example:

boolean output = (a > b) && (b > 0);

Enter fullscreen mode Exit fullscreen mode

Assignment Operators

  • Used to assign or update values in variables.
  • It is represented as "=" Example:
int x = 10;
x += 5;

Enter fullscreen mode Exit fullscreen mode

Top comments (0)