Branching Statements in java 7

In this section, we will discuss about Branching Statements in java 7. This is one type of control flow statement.

Branching Statements in java 7

In this section, we will discuss about Branching Statements in java 7. This is one type of control flow statement.

Branching Statements in java 7

Branching Statements in java 7

In this section, we will discuss about Branching Statements in java 7. This is one type of control flow statement.

Branching Statements :

Branching statements are categorize in the following types :

  • break statement
  • continue statement
  • return statement

Break Statement :

The functionality of break statement is to break the flow of your loop (do-while, while, for or switch statement). In switch statement we use break at the end of each case statement.

Syntax :

loop (...){
condition{
break;
}
......//statements
}

Continue Statement :

Continue statement is another branching statement provided by the java 7. Its functionality to stop the current iteration of the specified loop and continue execution with the next iteration.

Syntax :

loop (...){
condition{
continue;
}
......//statements
}

Return Statement :

It is another branching statement. The functionality of return statement is to exits the current method and it returns the flow of your control to the method is called.

return;

 You can also return some value by using the return statement.

return result;

Condition is that the data type of return value and the return type of method must be same.