¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita+ 2
what is the output for the program for(;;) java
public class Main { public static void main(String []args) { for(;;) { int i=0; if(i==1) { System.out.println(i); break; } ++i; } } }
4 Respuestas
+ 5
Why don't you try to learn it on Sololearn playground?
You can learn your code and see the output.
And then if you don't understand, you can ask us for sure.
It is a simple loop.
In this loop initialization, condition and iteration is break down into parts.
+ 2
Simple loop, but this one is infinite, never gonna break.
+ 1
It's a simple loop which print i, (0) and then break the loop.
The ++i doesn't occur by the "break" sentence written before
0
It goes infinite ,but never break