我是 Java 新手,遇到了一个带有“while”循环的程序,其条件是对象引用/调用。我彻底跟踪了代码,没有看到对象的任何终止条件(如果 while 循环条件中的对象具有“while”循环实现导致的终止条件,那将是有意义的)。
注意:这涉及“内部”/“嵌套”类,所以我什至不完全确定这就是它起作用的原因。这种语法方式如何满足循环?我将尝试在下面的伪代码中构建我的问题:
class DemoClass {
demoClassfoo() {
InnerClassdemo object2 = this.new InnerDemoClass;
// Here is where my confusion is. I always thought that the
// while loop had to terminate with a logical statement being
// satisfied: like it is calling an object?
while(object2.innerClassfoo()) {
IMPLEMENTATIONS;
}
}
class InnerDemoClass {
innerDemoClassfoo() {
IMPLEMENTATION;
}
}
public static void main(String[] args) {
DemoClass object = new DemoClass();
}
}