for( ; ; ;) in Java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

for( ; ; ;) in Java

How many times does this execute: for(;;;) { //some code } Can someone please explain how and why(I mean no initialization, no condition, no increment)? Thanks in advance.

28th May 2017, 4:33 PM
Deepesh Choudhary
Deepesh Choudhary - avatar
2 Answers
+ 6
infinite all condition are true
28th May 2017, 4:34 PM
MR Programmer
MR Programmer - avatar
+ 1
you can initialize the loop variable before for loop e.g. var i=0; then u can increment or decrement inside the loop. finally u can exit using break with if condition. this way, the loop wont run infinitely.
28th May 2017, 8:09 PM
Gurpreet Singh
Gurpreet Singh - avatar