Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training

Continue Statement in java 7

In this tutorial we will discuss about continue statement in java 7.

Ads

Continue Statement in java 7

In this tutorial we will discuss about continue statement in java 7.

Continue Statement :

Sometimes you need to skip block of statements under specific condition so for that you can use continue statement in loops.

In java 7, Continue statement stops the current iteration of a for, switch, do-while loop and continue execution with the next iteration. You can categorize continue statement into two parts -

  • Unlabeled Continue Statement - It skips the present iteration of the innermost loop
  • Labeled Continue Statement

Unlabeled Continue Statement : It skips the present iteration of the innermost loop.

Labeled Continue Statement : This is used where more than one loops are used. It leaves the present iteration of the loop which you can marked with the given label.

Example :

package branching;

class ContinueStatement {
	public static void main(String[] args) {
		int i;
		for (i = 1; i <= 10; i++) {
			if (i % 2 == 0) {
				System.out.println("Continue statement is called even number...");
				continue;
			}
			System.out.println("Value of i :" + i);
		}
	}
}

Output :

Value of i :1
Continue statement is called even number...
Value of i :3
Continue statement is called even number...
Value of i :5
Continue statement is called even number...
Value of i :7
Continue statement is called even number...
Value of i :9
Continue statement is called even number...

Advertisements

Ads
Share on Google+Share on Google+

Continue Statement in java 7

Posted on: December 24, 2012 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: Continue Statement in java 7  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads