Java Bug Hunt Easy +10 XP
Missing Semicolon
This code won't compile. Find the fix.
JavaFind the bug
1
int sum = 0;2
for (int i = 0; i < 10; i++) {3
sum += i4
}5
System.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.