Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
45 views2 pages

Experiment-5 AIM: Use of Labelled Break and Continue .: CSE-4 Chandigarh University

The document describes two Java programs that demonstrate the use of labelled break and continue statements. The first program uses a labelled break statement to break out of both the inner and outer for loops after the inner loop counter j reaches 10. The second program uses a labelled continue statement to skip the remaining code in the inner for loop and continue with the next iteration of the outer for loop when the inner counter j equals 5. Both programs are examples of using labels to control the flow of nested loops in Java.

Uploaded by

Naimish Dixit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views2 pages

Experiment-5 AIM: Use of Labelled Break and Continue .: CSE-4 Chandigarh University

The document describes two Java programs that demonstrate the use of labelled break and continue statements. The first program uses a labelled break statement to break out of both the inner and outer for loops after the inner loop counter j reaches 10. The second program uses a labelled continue statement to skip the remaining code in the inner for loop and continue with the next iteration of the outer for loop when the inner counter j equals 5. Both programs are examples of using labels to control the flow of nested loops in Java.

Uploaded by

Naimish Dixit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

CSE-4 Chandigarh University

Experiment-5

AIM: Use of labelled break and continue .

1. Labelled Break.

class BreakWithLable
{
public static void main(String args[])
{
int i,j;
outer:for(i=0;i<3;i++)
{
System.out.print("Pass "+i+":");
for(j=0;j<20;j++)
{
if(j==10)
break outer;
System.out.print(j+" ");
}
System.out.println("This will not print");
}
System.out.println();
System.out.println("Loops complete");
}}
CSE-4 Chandigarh University

2. Labelled continue.
class ContinuethLable
{
public static void main(String args[])
{
int i,j;
Outer:
for(i=0;i<10;i++)
{
System.out.println();
System.out.print("Pass "+i+":");
for(j=0;j<10;j++)
{
if(j == 5)
continue Outer;
System.out.print(j+" ");
}}
System.out.println();
System.out.print("Loops Complete");
}
}

You might also like