+ 1

// Why is the outprint of this code's outprint says exection time out

public class Program { public static void main(String[] args) { int x = 2; while (x>0); { System.out.println(x); x--; } } }

12th Sep 2021, 2:33 AM
宋连城
5 Réponses
+ 2
Don't use Semicolon for WHILE loop. If used it'll pop up execution time out.
12th Sep 2021, 3:10 AM
Sai Sudarshan B V
+ 2
difference is semicolon; after while
12th Sep 2021, 3:17 AM
zemiak
+ 1
宋连城 Semicolon (;) breaks statement in Java. The scope of the statement will be till Semicolon so that was the problem.
12th Sep 2021, 5:45 AM
A͢J
A͢J - avatar
+ 1
Remove ; after while stmt
12th Sep 2021, 8:44 AM
Rahul Yadav
Rahul Yadav - avatar