Volume of a wheel

Math has been an integral part of almost every culture from the time civilization began. From the ancient Indians, to the ancient Greeks, every civilization gave importance to math. As vast and…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




CONTROL STATEMENTS IN JAVA.

control statements in java

If statement:

if statement is the most basic of all the control statements. It tells your program to execute a certain section of code only if a particular test evaluates to true. An if statement consists of a boolean expression followed by one or more statements.

Syntax:

if (Boolean-expression) {

statement;

}

If-else statement:

An if statement can be followed by an optional else statement, which executes when the boolean expression is false.

Syntax:

If (Boolean-expression) {

Statement;

}

else {

statement;

}

Switch statement:

A switch statement allows a variable to tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case.

Syntax:

switch(expression){

case constant-expression :

Statement(s);

break;

case constant-expression :

Statement(s);

break;

default:

statements;}

for loop

A for loop is a repetition control structure that allow you to efficiently write a loop that needs to execute a specific number of times.

Syntax:

}

while Loop :

while loop executes a statement repeatedly, until the value of condition becomes false. The test takes place before each iteration.while loop executes a statement repeatedly, until the value of condition becomes false. The test takes place before each iteration.

Syntax:

while(Expression){

Statement(s);

}

do-while Loop :

Unlike for and while loops, which test the loop condition at the top of the loop, the do..while loop checks the condition at the bottom of the loop.

A do..while loop is similar to the while loop, except that a do..while loop is guaranteed to execute at least one timeUnlike for and while loops, which test the loop condition at the top of the loop, the do..while loop checks the condition at the bottom of the loop.A do..while loop is similar to the while loop, except that a do..while loop is guaranteed to execute at least one time

Syntax:

do{

Statement(s);

}while(Expression);

Add a comment

Related posts:

Testing Spring Controller

Spring is an open-source framework based on the Java language, and here Controller is a class to handle requests coming from the client. Today we will learn about Spring Controllers and how to test…

Todo santo dia

Meu pai acorda como se o sol dormisse com ele. Um desperta quando o outro se mexe. Nada de preguiça nem protesto, já que a rotina não é fardo, é bênção. Abre os olhos e habitua-se ao quarto que nasce…

Learning from the experts

Learning is always an ongoing process, This past week what we learned was invaluable to the process of being in an interview. We learned that doing the extra hardwork always pays off, if not in the…