The general form of the if statement is
if( boolean_value ) { // Execute these statements }
If the boolean value inside the if statement evaluates to false then an else block can be executed:
if( boolean_value ) { // boolean is true: Execute these statements } else { // boolean is false: Execute these statements }
There is not a limit to the number of else if statements that can follow an if statement.
The switch statement only evaluates int variables or variables that can be converted to int.
The do-while statement assures that the body of the loop is evaluated at least once.
An infinite loop is a loop that does not terminate; its loop control variable never evaluates to a value that allows the loop to exit. For example:
int a = 10; while( a > 0 ) { // Never change the value of a }
The most popular type of loop for iterating over a variable or set of variables is the for loop.
You can skip the statements in the current iteration of a loop by issuing the continue statement.
You can stop executing the statements in a loop and continue at the first line following the loop by issuing the break statement.
You can break out of a multiple nested loop by defining a label and then breaking to the label, for example:
outer: for( int a=0; a<10; a++ ) { for( int b=0; b<10; b++ ) { if( a * b == 25 ) break outer; } }