Skip to main content
Java Bug Hunt Easy +10 XP

Missing Semicolon

This code won't compile. Find the fix.

JavaFind the bug
1int sum = 0;
2for (int i = 0; i < 10; i++) {
3 sum += i
4}
5System.out.println(sum);
The bug is on line 3

Select the correct fix

Show answer and explanation

Answer: Add ; after sum += i

Every statement in Java must end with a semicolon. The line sum += i is missing it.

Hint: Java requires statement terminators.

What this challenge tests

Bug Hunt in Java: syntax, basics.

Related challenges