When would you write an infinite loop in Java? -
what practical applications infinite loops in java?
for example:
while(true){ //statements, loop never set false }
when use this?
infinite in sense until changes want keep running. until user hits "exit" keep running program.
in example need in code break it.
if (this happens) break end
but might put boolean instead of counter < 1 in while loop. in example it's bad practice.
program guess age initialize age while (age != 20) guess user age = guess user end
Comments
Post a Comment