Skip to content
Veltoryx Technologies
ProLesson 2.3Beginner3 min readUpdated 30 October 2026

Operators

Arithmetic, comparison, logical and assignment operators, the ++ puzzle, short-circuiting and the ternary operator.

Operators are the symbols that do work on values: add them, compare them, combine conditions. Most look like school maths, with a few Java twists that interviewers love.

01Arithmetic

Arithmetic.java
public class Arithmetic {
    public static void main(String[] args) {
        int a = 17, b = 5;
        System.out.println(a + b);   // 22
        System.out.println(a - b);   // 12
        System.out.println(a * b);   // 85
        System.out.println(a / b);   // 3 (integer division)
        System.out.println(a % b);   // 2 (remainder)
        System.out.println(-17 % 5); // -2 (sign follows the left side)
    }
}
Expected output
22
12
85
3
2
-2

% (modulo) gives the remainder. It's handy for "is this number even?" (n % 2 == 0) and for wrapping around, like days of the week.

Loading the rest of the lesson…