What is time limit exceeded???? java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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!"); } }

13th Feb 2017, 12:49 PM
Hichem Chekir
Hichem Chekir - avatar
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.
13th Feb 2017, 3:25 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 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.
13th Feb 2017, 1:00 PM
Megatron
Megatron - avatar