|
|
|
|
|
|
|
|
|
|
|
|
|
|
JAVA PROGRAMMING
The break statement The break statement has two forms: unlabelled and labeled. You saw the break statement in action within the switch statement earlier. As noted there, break terminates enclosing the switch statement and flow of control transfers to the statement immediately following the switch. You can also use the unlabelled form of the break statement to terminate a for, while, or do-while loop. An example code using unlabeled break While, the unlabelled form of the An example code using labeled break The continue statement You use the continue statement to skip the current iteration of a for, while , or do-while loop. The unlabelled form skips to the end of the innermost loop's body and evaluates the boolean expression that controls the loop, basically skipping the remainder of this iteration of the loop. The return statement The last of Java's branching statements is the
return statement. You use return to exit from the current method and jump
back to the statement within the calling method that follows the original
method call. There are two forms of return: one that returns a value and
one that doesn't. To return a value, simply put the value (or an
expression that calculates the value after the return keyword:
|
|
||||||||
|
|
||||||||||
|
|
||||||||||
|
|
||||||||||
|
|