Saturday, 4 January 2014

Iteration statement:while loop


How to use Java while:

Using while loop

While loop:

The while loop is java’s most fundamental looping statement.It repeats a statement or block while its controlling expression is true.In while statement condition can be any boolean expression.

Iteration statements:for loop in java

The most common iteration Statements in Java

Iteration Statement: for loop


The 'for' LOOP:


The for statement provides a compact way to iterate over a range of values. Programmers often refer to it as the "for loop" because of the way in which it repeatedly loops until a particular condition is satisfied. If only one statement being repeated, there is no need for the curly braces. When using this version of the for statement, keep in mind that,The initialization expression initializes the loop; it's executed once, as the loop begins.

Switch Statement in Java

How to use Java Switch: Case: Default: 

Using switch statement

Swich:

The switch statement is Java’s multiway branch statement.It provides an easy way to dispatch execution to different parts of your code based on the value of an expression.It is an alternatives of else-if ladder. Switch allows you to choose a block of statements to run from a selection of code, based on the return value of an expression. The expression used in the switch statement must return an int, a String, or an enumerated value.

Friday, 3 January 2014

Nested if Statement in Java

The most common Control Statements in Java

Control Statement Nested if


The nested if Statement:

Nested if are very common in programming. Nesting an if  Statement just means putting one if Statement inside of another. when you nest ifs, the main thing to remember is that an else statement always refers to the nearest if statement that is with  in the same block as the else and that is not already associated with an else.