25.02.2017 Views

java_tutorial

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Java<br />

nested if<br />

statements<br />

You can use one if or else if statement inside another if or else<br />

if statement(s).<br />

switch statement<br />

A switch statement allows a variable to be tested for equality<br />

against a list of values.<br />

If Statement in Java<br />

An if statement consists of a Boolean expression followed by one or more statements.<br />

Syntax<br />

Following is the syntax of an if statement:<br />

if(Boolean_expression)<br />

{<br />

}<br />

//Statements will execute if the Boolean expression is true<br />

If the Boolean expression evaluates to true then the block of code inside the if statement<br />

will be executed. If not, the first set of code after the end of the if statement (after the<br />

closing curly brace) will be executed.<br />

Flow Diagram<br />

73

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!