0
What is time limit exceeded???? java
I wrote this program in java and the console tells me time limit exceeded: public class Program { public static void main(String[] args) { int x=15; { while(x<56); System.out.println(x); x++; } System.out.println("STOOPP!"); } }
2 Answers
+ 4
x=15 means x<56 is always true. while(x<56); is an infinite loop and that's why time limit is exceeded.
+ 2
public class Program
{
public static void main(String[] args) {
int x=15;
while(x<56)
{
System.out.println(x);
x++;
}
System.out.println("STOOPP!");
}
}
//semicolon removed after while.
//brackets position changed.
this will resolve your error.
if program is taking too much time to complete then online compilers produce time limit exceeded error.