我目前正在根据教科书开展一个项目,并且我在 while 循环中遇到了一个晦涩的问题。教科书的代码如下;
while(getImage().getWidth(applet) <= 0);
double x = applet.getSize().width/2 - width()/2;
double y = applet.getSize().height/2 - height()/2;
at = AffineTransform.getTranslateInstance(x, y);
我从未见过最后用分号声明的 while 循环,所以我将我的代码解释为标准;
while(getImage().getWidth(applet) <= 0) {
double x = applet.getSize().width/2 - width()/2;
double y = applet.getSize().height/2 - height()/2;
at = AffineTransform.getTranslateInstance(x, y);
}
有人可以解释两者之间的区别吗?我将我的代码更改为像第一个一样,我的程序运行得很好,但是我不明白其中的区别。