Java program use of continue

March 29, 2022 · Team EasyExamNotes · 2 min read (est.) · 0 comments

Share on WhatsApp

PROGRAM:

To show use of Continue statement.

/**
             * @Prof. Jayesh
             * continue is a control statement.
             * continue brings compiler to the top of execution structure.
             */

public class ExampleOfContinue {

            public static void main(String args[])
            {

            int num[]={1,2,3,4,5,6,7,8,9,10};
            System.out.println(“Show all numbers except 5”);
            int i;

            for(i=0;i = num.length;i++)
            {
                        if(num[i]==5)
                                    continue;
                        else
                                    System.out.println(num[i]);
            }
            }
}

OUTPUT:
Show all numbers except 5
1
2
3
4
6
7
8
9

10

Discussion

Ask a question, share your thoughts or report an error.

Sign in to participate in the discussion.

Join the discussion