Can a for loop be written to create an infinite loop or is it only while loops that do that?

前端 未结 12 1485
时光取名叫无心
时光取名叫无心 2021-01-17 23:58

Can a for loop be written in Java to create an infinite loop or is it only while loops that cause that problem?

12条回答
  •  无人共我
    2021-01-18 00:50

    Sure you can

    for(int i = 0; i == i; i++) {}
    

    Any loop can be made infinite as long as you make a way to never hit the exit conditions.

提交回复
热议问题