| else |
|
grammar |
| |
A control flow statement that is used in conjunction with an
if
statement.
When the expression associated with the
if
statement evaluates to zero, then the block of statements associated with the
associated
else
statement is executed.
Its usage description can be summarized as follows:
Statement:
if ( Expression ) Statement else Statement
| |
| Example: |
The following example shows how several
if/else
statements can be chained together.
In some cases, incidentally, a
switch
statement may be appropriate as an alternative.
import yoix.util.Calendar.*;
Calendar c;
stdout.nextbuf = "Today is ";
if(c.dayofweek == SUNDAY)
stdout.nextline = "Sunday";
else if(c.dayofweek == MONDAY)
stdout.nextline = "Monday";
else if(c.dayofweek == TUESDAY)
stdout.nextline = "Tuesday";
else if(c.dayofweek == WEDNESDAY)
stdout.nextline = "Wednesday";
else if(c.dayofweek == THURSDAY)
stdout.nextline = "Thursday";
else if(c.dayofweek == FRIDAY)
stdout.nextline = "Friday";
else if(c.dayofweek == SATURDAY)
stdout.nextline = "Saturday";
else
stdout.nextline = "indeterminate!";
The text on standard output might look like:
Today is Sunday
| | |
| See Also: |
if,
reference,
switch
|
|
Yoix is a registered trademark of AT&T Intellectual Property.
|