% gives the remainder after integer division — what is left over. 7 % 3 is 1 (because 7 = 2×3 + 1). It is handy for tests like even/odd: n % 2 is 0 for even numbers.
%
7 % 3
1
n % 2
System.out.println(7 % 3); // 1 System.out.println(10 % 2); // 0 System.out.println(9 % 5); // 4
▶ Try it: run this, then change something and run it again.
What is 7 % 3?
Type exactly what this prints:
System.out.println(10 % 2);
What is 9 % 5?
9 % 5
Match each expression to its result.