Continue statement in Java

Published on July 17, 2015 by abundantcode

Filed under Java

Last modified July 17, 2015

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 3297 times

The continue statement in java lets the developers to skip the current iteration within the loop statements like for , while or do-while . As soon as the java compiler figures out the continue keyword in the code , it immediately skips the statements that follow the continue keyword and then proceeds with the next iteration.

The break statement jumps out of the loop completely whereas the continue just skips the current iteration.

Continue statement in Java

Below is a sample code snippet demonstrating the usage of the continue statement in java

package com.abundantcode;

import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args)
    {
        List<String> input = new ArrayList<String>();
        input.add("Abundantcode.com");
        input.add("Programming Website");
        input.add("Java Tutorials");
        for(String item:input)
        {
            if(item=="Java Tutorials")
                continue;
            System.out.println(item);
        }
    }
}

image

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Comment


x

You might be Interested in these Posts

C Program to find the G.C.D of a number using Recursive function

Problem Write a program in C to find the find the G.C.D of a number using recursion and display the ...

C Program to display Inverted half-pyramid using *

Problem Write a program in C to print Inverted half-pyramid using * as shown below.The program shou...

C Program to print a Half Pyramid using *

Problem Write a program in C to print Half pyramid using * as shown. * * * * * * * * * * ...