Answers for "labelled loops in java gfg"

0

labeled for loop in java

//WithLabelledLoop.java

    class WithLabelledLoop
    {
        public static void main(String args[])
        {
            int i,j;

            loop1:   for(i=1;i<=10;i++)
            {
                System.out.println();

                loop2:   for(j=1;j<=10;j++)
                {
                    System.out.print(j + " ");

                    if(j==5)
                        break loop1;     //Statement 1
                }
            }
        }
    }

    Output :

                1 2 3 4 5
Posted by: Guest on November-27-2019
0

labeled for loop in java

//WithLabelledLoop.java

    class WithLabelledLoop
    {
        public static void main(String args[])
        {
            int i,j;

            loop1:   for(i=1;i<=10;i++)
            {
                System.out.println();

                loop2:   for(j=1;j<=10;j++)
                {
                    System.out.print(j + " ");

                    if(j==5)
                        break loop1;     //Statement 1
                }
            }
        }
    }

    Output :

                1 2 3 4 5
Posted by: Guest on November-27-2019

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language