How to Continue a Loop in Java


In this example, we will learn the method to continue a loop in Java.

Source Code

package com.beginner.examples;

public class ContinueLoop {
  public static void main(String[] args) {
    for (int k = 0; k < 3; k++) { // loop
      if (k == 1) continue; // continue
      System.out.println(k);
    }  
  }
}

Output:

0
2
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments