Fundamentals8 / 25
Up next

Numeric types

class Main {
    public static void main(String[] args) {
        int a = 7;
        int b = 2;
        System.out.println(a + " " + (a - b) + " " + (a * b));
        // integer division truncates; % is the remainder
        System.out.println(a / b + " " + a % b);
        // cast one side to get floating-point division
        System.out.println((double) a / b);
    }
}
What you're solving

int, double, and their operators