0% found this document useful (0 votes)
19 views11 pages

JAVA Report

This report explores the use of continue statements and labels in Java programming, detailing their functionality within loop control structures. It explains how the continue statement allows for skipping iterations in loops and provides examples of its implementation, including labeled continues. The document also highlights the differences between unlabelled and labelled continues.

Uploaded by

dunuchiedozie
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)
19 views11 pages

JAVA Report

This report explores the use of continue statements and labels in Java programming, detailing their functionality within loop control structures. It explains how the continue statement allows for skipping iterations in loops and provides examples of its implementation, including labeled continues. The document also highlights the differences between unlabelled and labelled continues.

Uploaded by

dunuchiedozie
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/ 11

FEDERAL UNIVERSITY OF TECHNOLOGY OWERRI

PMB 1526 OWERRI, IMO STATE

A REPORT ON

HOW CONTINUES AND LABEL ARE USE IN JAVA PROGRAM

COURSE

STRUCTURED PROGRAMMING (CSC307)

SUBMITTED BY

DUNU CHIEDOZIE RAPHAEL

20201214582

TO

DEPARTMENT OF COMPUTER SCIENCE

SCHOOL OF INFORMATION AND COMMUNICATION TECHNOLOGY

i
DEDICATION
I dedicate this project to GOD, in spite of all the obstacles I‘ve faced, he has led me this far in

my life and in my studies and to my parents for training me to school.

ii
ACKNOWLEDGEMENTS
I want to thank The Head of department ; Dr. (Mrs) J.N. Odii, and all other lecturers and

organizers of this important course for devoting their efforts to make sure we could learn and get

the experience we needed to get ready for the industry in our field of study.

iii
ABSTRACT
This report provides a comprehensive exploration of how continuous and label works in JAVA

program.

Iv
TABLE OF CONTENT
Title page

Dedication

Acknowlegment

Abstract

Table of content

Introduction

Java continue statement

Java continue statement with inner loop

Labels

Continue statement with labels

Differences

Summary

Reference

v
INTRODUCTION
Java Continue Statement
The continue statement is used in loop control structure when you need to jump to
the next iteration of the loop immediately. It can be used with for loop or while
loop.

The Java continue statement is used to continue the loop. It continues the current
flow of the program and skips the remaining code at the specified condition. In
case of an inner loop, it continues the inner loop only.

We can use Java continue statement in all types of loops such as for loop, while
loop and do-while loop.

i.e

jump-statement;
continue;

ILLUSTRATION ON HOW JAVA CONTINUE STATEMENT IS


USED AND THE OUTPUT
ContinueExample.java

//Java Program to demonstrate the use of continue statement


//inside the for loop.
public class ContinueExample {
public static void main(String[] args) {
//for loop
for(int i=1;i<=10;i++){
if(i==5){
//using continue statement
continue;//it will skip the rest statement
}
System.out.println(i);
}
}
}

THE OUTPUT:
1
2
3
4
6
7
8
9
10

As you can see in the above output, 5 is not printed on the console. It is because the
loop is continued when it reaches to 5.
LABELS
A Label object is a component for placing text in a container. A label displays a
single line of read-only text. The text can be changed by the application, but a user
cannot edit it directly.

JAVA CONTINUE STATEMENT WITH LABEL


We can use continue statement with a label. This feature is introduced since JDK
1.5. So, we can continue any loop in Java now whether it is outer loop or inner.

example of java continue statement with labelled for loop

ContinueExample3.java

//Java Program to illustrate the use of continue statement


//with label inside an inner loop to continue outer loop
public class ContinueExample3 {
public static void main(String[] args) {
aa:
for(int i=1;i<=3;i++){
bb:
for(int j=1;j<=3;j++){
if(i==2&&j==2){
//using continue statement with label
continue aa;
}
System.out.println(i+" "+j);
}
}
}
}

THE OUTPUT:

1 1
1 2
1 3
2 1
3 1
3 2
3 3

DIFFERENCE BETWEEN CONTINOUS AND A LABELED CONTINOUS

An unlabelled continue is used to skip the iteration of the nearest closing loop but
labeled continue is used to skip the iteration of the desired closing loop.
SUMMARY
 A continue goes to the end of the loop in which it resides.

 A break exits the loop in which it resides.

 A labelled break exits (goes to the end of) the labelled block

.
REFERENCES
Continues and labels on java on youtube.com Author: Simply coding
How java works on youtube.com Author: Telusko
Java: A Beginner's Guide. Author: Herbert Schildt.
Effective Java. Author: Joshua Bloch

You might also like