when to use while loop rather than for loop

前端 未结 14 1000
清酒与你
清酒与你 2020-12-06 02:59

I am learning java as well android. Almost everything that we can perform by while loop those things we can do in for loop.

I found a simple condition where using w

14条回答
  •  粉色の甜心
    2020-12-06 03:17

    for is finite, in the sense that it will finish looping when it runs out of elements to loop through....

    while can be infinite if a condition isn't met or the loop broken

    Edit

    My mistake ... for can be infinite ..

提交回复
热议问题