Home Java Java-break-example Java Break continue
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Java Break continue

Advertisement
Java has two keywords break and continue in its branching category. 'break' allows users to give end to a loop whereas with 'continue' statement flow of control inside a loop can be continued even when the specified loop condition is false.

Java Break continue

     

Java has two keywords break and continue in its branching category. 'break' allows users to give end to a loop whereas with 'continue' statement flow of control inside a loop can be continued even when the specified  loop condition is false. 'continue' statement returns the program control from the point where it is passed.

Break and Continue in Java

public class Java_Break_continue {
public static void main(String argv[]) {

char [] c = {'J','a','v','a','*'};
String str[] = {"continue","break","statement","example"};
char c_1 = c[4]; 
byte i = 0;
do{
System.out.print(" " + c[i]);

i++;

if(c[i] == c_1)
break;
else
continue;
}while(c.length > i);



System.out.println(" ");

for(int j = 0; j < str.length; j++){
System.out.print(str[j] + " ");
if(j < str.length)
continue; // from here the program control is returned back
System.out.println("woooooooooooooooooo");
}
}
}

Download the code

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



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: November 11, 2008

Related Tutorials

Ask Questions?    Discuss: Java Break continue  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
Ravindra kumar Chakravarti
November 11, 2011
progamming

very good programming
DMCA.com