Control Statements in JAVA

If you are familiar with C, C++ control statements then it will be easier for you to understand the control statements here and if not then also it will be easier to understand 😉

So let’s have a closer look.

JAVA has three types of control statements:

  1. Selection Statement
  2. Iteration Statement
  3. Jump Statement

In Selection Statement,  if you want your program to follow different paths of execution based on the outcome of the expression or the condition, then selection statements will be used. to understand better follow this example of flow chart.

To understand better follow this example of flow chart:

Here, if you have only one or two paths then you can use if  else statement, and for multiple branching, you can use switch case .selection_structure_modified.png

In Iteration Statement, you can repeatedly execute the same set of instructions until the condition satisfies. This will create a loop. These also create loops.

Here, have a look at the flow chart of loop, that would explain you the concept:

loop.jpg

In Jump Statement, you can transfer the control to another part of your program. JAVA mainly has three jump statements:

break, continue and return.

In C you might have learnt about goto statement. goto statement is not supported in JAVA.

jump statement.jpg

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Powered by WordPress.com.

Up ↑

%d bloggers like this: