About Question enthuware.ocajp.i.v7.2.848 :
Posted: Tue Mar 20, 2012 11:12 am
Pay attention on this one:
public class TestClass {
public static void main(String[] args){
int k = 2;
do{
System.out.println(k);
}while(--k>0)
}
}
note that the while statement does not end with a semicolon and the program says that the answer is 2 1.
Correct if I am wrong, but isn't it a little confusing, I mean you don't know if you must consider that an semicolon is misplaced or that it doen't exists at all
public class TestClass {
public static void main(String[] args){
int k = 2;
do{
System.out.println(k);
}while(--k>0)
}
}
note that the while statement does not end with a semicolon and the program says that the answer is 2 1.
Correct if I am wrong, but isn't it a little confusing, I mean you don't know if you must consider that an semicolon is misplaced or that it doen't exists at all