Answers for "java while continue"

2

java how to continue outer loop

public class Test {
    public static void main(String[] args) {
        outerloop:
        for (int i=0; i < 5; i++) {
            for (int j=0; j < 5; j++) {
                if (i * j > 6) {
                    System.out.println("Breaking");
                    break outerloop;
                }
                System.out.println(i + " " + j);
            }
        }
        System.out.println("Done");
    }
}
Posted by: Guest on March-11-2021
2

continue in java

int i=0;
while(i<10){
  if(i%2==0){
    i++;
    continue;// If it's pair we return to the while
  }
  System.out.println(i);// If is not we print it.
  i++;
}
Posted by: Guest on January-09-2021
1

Continue statement in java

// continue in java example
import java.util.*;
public class ContinueJavaExample 
{
   public static void main(String[] args) 
   {
      for(int a = 1; a <= 10; a++)
      {
         if(a % 2 != 0)
         {
            continue;
         }
         System.out.println(a + " ");
      }
   }
}
Posted by: Guest on December-01-2020
2

continue in java

int i = 0;
while (i < 10) {
  if (i == 4) {
    i++;  //why do I need this line ?
    continue;
  }
  System.out.println(i);
  i++;
}
Posted by: Guest on June-17-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language