i have tested following code which might print 0 and 2 but it print 1 and 1 why?
public class break_command {
public static void main(String[] args) {
for (int i=0;i<10;i++){
for (int j=1;j<10;i++){
if ((i+j) %2==0){
System.out.println("i "+ i +" j " +j);
break;
}
}
break;
}
}
}
result//
i 1 j 1
BUILD SUCCESSFUL (total time: 0 seconds)
Is the line:
Supposed to be j++ not i++?
Otherwise it means on the first iteration:
Will be true.