Sunday 26 March 2017

Java Control Statements



Introduction:

  The program we have created so far, consist simple and leaner code. But in real life, it is necessary to change to order of execution of the instructions based on certain conditions. This involves decision making, i.e. taking a decision based on certain conditions at run time. This decision making is created with flow control.
  Flow control not only allows us to execute statement conditionally, it also provides mechanism to skip statements, jump between statements and perform looping. Most of our code algorithm will be composed of combination of flow-control statements and regular statements.
  Decision making in Java is done on the basis of the following kind of statements:

❯❯ Selection Statements
❯❯ Iteration Statements
❯❯ Jump Statements

Selection Statements:

Selection statement provides a way to change the normal course of the program based on an expression. This is known as branching. Java enables us to branch using two such decision making or control statements:

❯❯ The if-else statement
❯❯ The switch statement

Iteration statements

These statements execute a set of code repeatedly as long as condition is met. These statements are in general known as loops. In Java, There three types of loops.

❯❯ The while statement
❯❯ The do-while statement
❯❯ The for statement

Jump Statements

❯❯ The break Statement
❯❯ The continue Statement
❯❯ The return Statement

 Next Topic Shahbaz

0 comments:

Post a Comment

Powered by Blogger.

Stats