+ 2

Why we have "3" in the output? Thanks

public class Program { public static void main(String[] args) { int x = 1; do { System.out.println(x); x++; if(x==3){ continue; } } while(x <= 5); } } output 1 2 3 4 5

13th Feb 2017, 7:26 PM
arp diallo
arp diallo - avatar
4 Answers
+ 19
If you want to remove this number you have to place println function after the "if" condition.
13th Feb 2017, 7:33 PM
Igor Makarsky
Igor Makarsky - avatar
+ 5
because you first print value then writ the continue statement try it other way round
13th Feb 2017, 7:34 PM
Megatron
Megatron - avatar
+ 1
Because you print value before check. You should move println line below if clause.
13th Feb 2017, 8:24 PM
Sinan Ceylan
Sinan Ceylan - avatar
0
To initialize, to give condition and to increase or decrease the value.
19th Feb 2017, 10:19 AM
Ebru Edanur ƞentĂŒrk