Junior — Middle
How to implement a loop that will run unconditionally and infinitely?
sobes.tech AI
Answer from AI
In Java and Android, to create an infinite loop, you can use while(true) or for(;;).
Example with while:
while (true) {
// code that runs infinitely
}
Or with for:
for (;;) {
// infinite execution
}
This loop runs unconditionally and forever until externally interrupted (e.g., via break or exception).