Explain continue statement with example, JAVA Programming

Assignment Help:

Explain continue statement with example?

It is sometimes essential to exit from the middle of a loop. Sometimes you'll need to begin over at the top of the loop. Sometimes you'll need to leave the loop completely. For these reasons Java gives the break and continue statements.

A continue statement returns to the starting of the innermost enclosing loop without completing the rest of the statements in the body of the loop. If you're in a for loop, the counter is incremented. For instance this code fragment skips even parts of an array

for (int i = 0; i < m.length; i++) {
   if (m[i] % 2 == 0) continue;
  // process odd elements...
 }

The continue statement is rarely used in practice, perhaps since most of the examples where it's meaningful have simpler implementations. For example, the above fragment could equally well have been written as

for (int i = 0; i < m.length; i++) {
   if (m[i] % 2 != 0) {
    // process odd elements...
   } 
}

There are just seven uses of continue in the whole Java 1.0.1 source code for the java packages.


Related Discussions:- Explain continue statement with example

I want selenium based test automation for java, I want Selenium Based Test ...

I want Selenium Based Test Automation for Java Based Web Application Project Description: I want some test cases to be automated to login to UI which is Java based web applic

Pebble merchant., there is a pebble merchant. he sells the pebbles,that are...

there is a pebble merchant. he sells the pebbles,that are used for shining the floor.his main duty is to take the length of the room side but he sometines mistakes doing that and m

Beam, program for hinged beam

program for hinged beam

Component developer to code in java, Component Developer to code in Java: ...

Component Developer to code in Java: Worked for Sansri's Gateway as Software Engineer . Here I Worked as a Component Developer to code in Java and J2EE technologies Here Ensu

Give an example for using getter methods, Give an example for Using Getter ...

Give an example for Using Getter Methods ? class CarTest6 { public static void main(String args[]) { Car c = new Car(); c.setLicensePlate("New York A45 636"); c.setMa

What are checked and unchecked exception, What are Checked and UnChecked Ex...

What are Checked and UnChecked Exception? A checked exception is some subclass of Exception (or Exception itself), excluding class RuntimeException and its subclasses. Making a

Boardcolourling, write a program to find the minimum no of colors to fill a...

write a program to find the minimum no of colors to fill a board where some of the elements of different color are already placed.

Describe the relational operators in java, Describe the relational operator...

Describe the relational operators in java? Java has six relational operators which compare two numbers and return a boolean value. The relational operators are , > , , >=

Describe remote objects?, Describe Remote Objects A Remote Object is o...

Describe Remote Objects A Remote Object is one whose functions can be called from another JVM. A remote object class must execute the Remote interface. A RMI Server is an appl

Java expert with tomcat tuning experience required, Java expert with tomcat...

Java expert with tomcat tuning experience needed Project Description: Want a Java expert to fix memory issues with tomcat. I need School java project - Threads Programm

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd