File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes break and contine in blocks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "break and contine in blocks" Watch "break and contine in blocks" New topic

break and contine in blocks

Lokanadham Nalla

Joined: Jul 21, 2005
Posts: 7

break block;

continue block;
1 is valid and 2 is invalid,

Can we apply break to block statements? Is it valid?
abhishek chauhan

Joined: Jul 21, 2005
Posts: 8
a label break statement can be used to terminate any labeled statements that contains break statement .. this could be a normal block also where as the continue statement can only be applied to the loops
Alangudi Balaji Navaneethan
Ranch Hand

Joined: Apr 28, 2004
Posts: 42
break statement is used in loops and in switch statements normally.

When used in switch case, control come out of the switch after executing break statement. Continue statement cannot be used with swith ... case statements.

continue statement takes the control to the test portion of the loop after executing itself. Then the loop will continue its body or not based on the test result.

if you think you can you r right<br />if you think you can not you r double right
Arulkumar Gopalan
Ranch Hand

Joined: Oct 13, 2003
Posts: 104
continue can indirectly act as a break also... check the code below.

Anbudan & Mahalo,<br />Arul<br /> <br />-Not a sun certified Java professional :-)
I agree. Here's the link:
subject: break and contine in blocks
It's not a secret anymore!