|
|
![]() | Syntax: if ( Expression ) Statement1
else Statement2
|
![]() | Semantics: The expression must be of type boolean.
If it evaluates to true, Statement1 is executed,
otherwise Statement2.
|
![]() | Again, blocks are to be used to compound several statements
into Statement1 or Statement2.
|
![]() | Our coding standard requires following layout:
if ( Expression ) { |
| HiLo.java |
// guess != secretNumber
if (guess < secretNumber) {
System.out.println("Too small!");
} else {
// guess > secretNumber
System.out.println("Too large!");
}
|
|
| Copyright © 2001, 2002 Andreas Borchert, converted to HTML on February 11, 2002 |