I am very very new at this java thing, and I am trying to count to 10 and display only the odd integer values using a continue statement. I can get the code to skip the integer I specify in line 5 but how do I do multiple integers (skip 2,4,6,8,10)? 1. public class App { 2. public static void (String[] args){ 3. 4. for (int x = 1; x <= 10; x++) { 5. if (x == 2) 6. continue; 7. else 8. System.out.print(" " + x); 9. } 10. } 11. } Any help would be great.
Thomas Paul
mister krabs
Ranch Hand
Joined: May 05, 2000
Posts: 13974
posted
0
try this: 1. public class App { 2. public static void (String[] args){ 3. 4. for (int x = 1; x <= 10; x++) { 5. if (x%2 == 0) 6. continue; 7. else 8. System.out.print(" " + x); 9. } 10. } 11. }