Previous | Home | Next |
- In java every statement terminate with semicolon(;).
- Statements generally contain expressions (expressions have a value).
- One of the simplest is the Assignment Statement.
- Declaration Statement.
- Expression Statement.
- Control flow Statement.
- Increment Statement.
- Method Invocation Statement.
- Object Creation Statement.
- Control Statements.
- Conditional Execution And Selection.
- Repetition.
- Special Control Statements.
Syntax :
<variable> = <expression>;
Example :
int height; height = 34;
int number;
number = 4;
if (number < 10 ) { //expression statement System.out.println(number + " is less than ten"); }
a++;
System.out.println("Hello World!");
Bicycle myBike = new Bicycle();
Java also has control statements that allow repetitive execution of statements and conditional execution of statements. Java has the following types of control statements.
If Statements - conditional execution of a single statement.
If-Else Statements - conditional selection among two statements.
Switch Statements - conditional selection among several statements.
Extended If-Else Statements - conditional selection among several statements.
While Loops - pretest loops.
For Loops - pretest loops.
Do-While Loops - posttest loops.
Return Statements - return values from and terminate methods.
Continue Statements - skip the remaining statements in an iteration of a loop.
Break Statements - exit a loop or switch statement.
Previous | Home | Next |