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

Illustrate object-to-relational mapping?, O/R mapping is well suited for re...

O/R mapping is well suited for read, change, write centric applications and not suited for write centric applications where data is seldom read. Although this was usually true of m

For what purposes ftp is used in networks, For what purposes FTP is used in...

For what purposes FTP is used in networks? FTP is known as file transfer protocol it is basically used to download or upload files / data to a remote computer.

Android app development, Android App Development Project Description: ...

Android App Development Project Description: I am seeking a developer who can start an app from scratch and get it delivered to me as soon as possible. It is a minute android

Explain the three benefits of access protection, Explain the Three Benefits...

Explain the Three Benefits of Access Protection ? Access protection has three major benefits: 1. It permits you to enforce constraints on an object's state. 2. It gives a si

what is meant by binding in rmi, Binding is a method of associating or re...

Binding is a method of associating or registering a name for a remote object that can be used at a later time to look up that remote object. A remote object can be linked with a na

What restrictions are placed on method overriding, What restrictions are pl...

What restrictions are placed on method overriding? Overridden methods must have the similar name, argument list, and return type. The overriding method may not limit the access

Cyclos ussd and mobile banking ivr module, Cyclos USSD and mobile banking I...

Cyclos USSD and mobile banking IVR module Project Description: We previously have a Cyclos mobile banking solution deployed on our server with SMS banking module. The solu

Http tunneling and rmi calls across firewalls , RMI transport layer usually...

RMI transport layer usually opens direct sockets to the server. Several Intranets have firewalls that do not accept this. To get through the firewall an RMI call may be embedded wi

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