Java Operators

An operator is a symbol that performs an operation on operands.

CategoryOperators
Arithmetic+ - * / %
Unary++ -- + - !
Relational== != > < >= <=
Logical&& || !
Bitwise& | ^ ~ << >> >>>
Assignment= += -= *= /= %=
Ternarycondition ? a : b

Example

Java
int a = 10, b = 3;
System.out.println(a + b);
System.out.println(a / b);   // integer division
System.out.println(a % b);   // remainder
System.out.println(a > b && b > 0);
System.out.println(++a);     // pre-increment
System.out.println(--a);
int max = (a > b) ? a : b;
System.out.println("Max: " + max);
13 3 1 true 11 10 Max: 10
Pre vs Post increment++a increments first, then uses the value; a++ uses the value first, then increments.
Track your progress through the Java course