Write a program in java to demonstrate continue keyword?

public class ContinueExample

{

                public static void main(String arg[])

                {

                                for(int i=1;i<=10;i++)

                                {

                                                if(i==5)

                                                {

                                                                continue;

                                                }

                                                System.out.println(i);

                                }

                }

}

 

Continue Keyword.PNG

public class ContinueTest

{

                public static void main(String arg[])

                {

                                for(int i=1;i<=3;i++)

                                {

                                                for(int j=1;j<=3;j++)

                                                {

                                                                if(i==2 && j==2)

                                                                {

                                                                                continue;

                                                                }

                                                                System.out.println(i+" "+j);

                                                }

                                }

                }

}

Demonstrate Continue Keyword.PNG

, , , , , ,

Leave a Reply