+ 1
In while loop, why we first call the "System.out.prinlnt" and after declare the "x++" ?
2 odpowiedzi
+ 2
Cuz we need to execute our code once before changing variable's value
+ 1
while(condition){
//do stuff, print etc.
//update variable, x++ etc.
}
In every loop u first do "step" (printig, calculation...) and on the end (before next step) u update variables (x++ in this case) so if x was 1 before u entered loop it will print "1" and then increment x to 2; next step is printing "2" and x++(x=3) and so on, while condition is true...