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

前端 未结 12 1573
时光取名叫无心
时光取名叫无心 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:42

    Dont forget mistakes like

    for (int i=0; i<30; i++)
    {
        //code
       i--;
    }
    

    It's not as uncommon as it should be.

提交回复
热议问题