do-while and while comparison
问题 do-while: do { i++; ++j; System.out.println( i * j ); } while ((i < 10) && (j*j != 25)); I am learning about do-while vs while at the moment and would like to rewrite the above java fragment (already declared and initialized) using a while instead. Are the below rewritten codes correct way to do so: while: while ((i < 10) && (j*j != 25)) { i++; ++j; System.out.println( i * j ); } Cheers 回答1: The difference between a do-while and a while is when the comparison is done. With a do-while , you'll