Controlled Statement Assignment Help

Assignment Help: >> Elements of Java - Controlled Statement

Control Statement

Java supports two selection statements that are if and Switch. These statements permits you to control the flow of your program's execution based upon conditions knows just during run time. If your background in programming does not involve C/C++ you will be pleasantly surprised through the power and flexibility holds in these two statements.

The if statement is Java's conditional branch statement. Control statement can be used to route program execution by two different paths.  Here is the common form of the if statement .

if (condition ) statement1;

else statment2;

In the syntax, each statement might be a single statement or a compound statement enclosed within curly braces (which is, a block). A condition is any expression the returns a Boolean value. Here the else clause is optional.

The if works such as this. If the condition is true then statment1 is executed.  Or else, statement2 (if it exists) is executed. Within no case will both statements be executed. For instance, let consider the given example.

int a, b;

/ / ....

if(a < b) a= 0;

else b= 0;

Here if a is less than b, then a is set to zero. Or else, b is set to zero. With no case both set to zero.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd