About Question enthuware.ocajp.i.v8.2.1299 :
Posted: Tue Dec 12, 2017 3:00 pm
What will the following program print?
In do-while loop,The statement is executed first and then the condition is checked.So,shouldn't it check the outer while's condition every iteration and decrement the value of var by 1.Tell me what I am missing.
Code: Select all
class Test{
public static void main(String args[]){
int var = 20, i=0;
do{
while(true){
if( i++ > var) break;
}
}while(i<var--);
System.out.println(var);
}
}