Home Java Jdk7 Continue Statement in java 7
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Continue Statement in java 7

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

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...
Advertisement

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 24, 2012

Ask Questions?    Discuss: Continue Statement in java 7  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com