0
Can't someone fix all this challenges?
It's not really an infinite loop. https://prnt.sc/ntnms7
8 Antworten
+ 3
Here you can see it:
https://code.sololearn.com/c6BdfR5B0UBC/?ref=app
A do while loop executes once and then checks the condition. If the condition is true, repeat the loop.
A while loop checks first the condition and only if the condition is true it executes the code.
+ 1
Have you tried it in the code playground?
It is an infinite loop.
int x = 0;
Do{
System.out.println(x); //output: 0
x++; //x = 1
}while (x > 0) //true -> 1 > 0
+ 1
No it is not.
x will reach Integer.MAX_VALUE after a time and then adding 1 to it will set it to Integer.MIN_VALUE which is -2^31.
Denise Roßberg
+ 1
Real infinity does not exist either. No matter which data type you choose (int, long, BigInteger), you will find a technical barrier. But theoretically, this condition leads to an infinite loop.
0
Denise Roßberg
My problem is not about condition checking, it is about the variable size of an int.
0
A while(true) loop would be pretty much infinite. Or just a different break condition would help
0
stnwtr
Nice observation!