do-while and while comparison

后端 未结 4 2004
情话喂你
情话喂你 2021-01-05 20:09

do-while:

do
{ 
    i++; 
    ++j;
    System.out.println( i * j );

}
while ((i < 10) && (j*j != 25));

I am learning about do-w

4条回答
  •  情书的邮戳
    2021-01-05 20:53

    The key difference between do-while and while, with do-while you are guaranteed at least one run of your code before the checks.

    *It does not need to get anymore complicated than that.

提交回复
热议问题