Java Operators

Arithmetic Operators

Use arithmetic operators for basic math operations:

  • + : addition
  • - : subtraction
  • * : multiplication
  • / : division
  • % : modulus (remainder)
Loading...
Output:

Assignment Operators

These operators assign values or update existing ones:

  • =, +=, -=, *=, /=, %=
Loading...
Output:

Comparison Operators

Compare two values and return true or false:

  • ==, !=, >, <, >=, <=
Loading...
Output:

Logical Operators

Used for combining or inverting boolean expressions:

  • && – AND
  • || – OR
  • ! – NOT
Loading...
Output:

Increment & Decrement

Used to increase or decrease a value by one:

int x = 5;
x++;  //equivalent to x = x + 1
System.out.println(x);  // 6

Operator Precedence

Java follows the standard math order of operations. Use parentheses to ensure correct order.

Loading...
Output:

Practice Question

What will this print?

A. true
B. false
C. Error
Loading...
Output:

Need Help?

Ask the AI if you need help understanding or want to dive deeper in any topic