Hello Friends!!!
Welcome to passionforcs,
In this article, we are going to learn flow breaking statements. In Java, there are three different flow breaking statements such as, break, continue, and return.
Lets' understand the break statement is used to break the entire code block. We use break statement with switch statements to break the case statement. Even we can use the break statement to break the loop and we can use a break like goto (in C programming). Let's understand more about the different types of a break statement.
break with a switch statement that we have seen in one of the previous articles.
In this article, we are going to learn flow breaking statements. In Java, there are three different flow breaking statements such as, break, continue, and return.
Lets' understand the break statement is used to break the entire code block. We use break statement with switch statements to break the case statement. Even we can use the break statement to break the loop and we can use a break like goto (in C programming). Let's understand more about the different types of a break statement.
break with a switch statement that we have seen in one of the previous articles.
The second form of break statement is break the looping statements. The break statement is used to break the loop, it immediate terminates the loop and control moves to the next statement.
Syntax,
break
For example,
The third form of a break statement is to use the break statement like goto statement in C programming. Java does not support the goto statement but it works the way goto statement works.
Syntax,
break label;
Here label is any valid label name.
For example,
Refer the above code and you can get that break label works when condition returns true. i.e. when condition is true, break statement break the labeled statement and control goes to the next statement.
Try these examples and let me know whether you get the break statement or not. Till then Happy Coding...:) In the next article we will learn about continue the next jumping statement.
No comments:
Post a Comment