Wednesday, December 1, 2010

Java Tutorial #9

0
The If Statement in Java
The Basic Syntax of if statement in C++ is:

if(condition/s){
Statements;
}
elseif(condition/s){
Statements;
}
else{
Statements;
}

But this Syntax will not work in Java.  The new syntax of if statement in Java is:

if(condition/s){
Statements;
}
if(condition/s){
Statements;
}

In this first syntax, multiple ifs is acceptable to Java.  But if you like to implement the general concept of if-elseif-else statement (which is very similar to c++) to your Java Program, you can still use it using this syntax.

if(condition/s){
Statements;
}
else if(condition/s){
Statements;
}
else if(condition/s){
Statements;
}
else(condition/s){
Statements;
}

 Consider this example.







No Response to "Java Tutorial #9"

Post a Comment