Advertisement
desislava_topuzakova

Operator continue

May 28th, 2023
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class DemoContinue {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. //continue -> преминаваме към следващата итерация / стъпка
  8.  
  9. for (int number = 1; number <= 10; number++) {
  10. if (number % 2 == 0) {
  11. continue;
  12. } else {
  13. System.out.println(number);
  14. }
  15. System.out.println("The number is: " + number);
  16. }
  17.  
  18.  
  19. int price = 100;
  20. while (price > 0) {
  21. if (price >= 20 && price <= 40) {
  22. continue;
  23. }
  24. System.out.println("Price down");
  25. price -= 30;
  26.  
  27. }
  28. }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement