+ 1

Why doesn't this work and how can I get this to work?

for(int x=10; x<=100; x=x+10) { if(x == 30 && x == 50) { continue; } System.out.println(x); } /* Should output 10 20 40 60 70 80 90 100 */

18th Apr 2019, 4:36 PM
philip
philip - avatar
2 odpowiedzi
+ 4
"x == 30 && x == 50" will never be true because x can't be 30 and (&&) 50 at the same time. You probably want to use || (or)
18th Apr 2019, 5:04 PM
Anna
Anna - avatar
+ 1
Oh yes that works, thank you very much im just starting to learn Java
18th Apr 2019, 5:44 PM
philip
philip - avatar