0
Compiler says tume limit exceeded in output .
So I just started learning Java and got to the section of while loops and for some reason the compiler is returning time limit exceeded when I try to run this code :plz help public class Myclass{ public static void main(String[] args){ int x=7; while (x>0);{ System.out.println(x); x++; } } }
4 ответов
+ 1
thanks that helps !!
+ 4
It is an infinite loop, because x is always larger than 0. Try doing x-- instead of x++.
+ 2
your ; after while (x< 10); is the loop remove it to run.
0
I tried it and changed the code to
still turning up the same msg
public class Myclass{
public static void main(String[] args){
int x=7;
while (x< 10);{
System.out.println(x);
x++;
}
}
}