Aqua Phoenix
     >>  Lectures >>  Java 1  
 

Navigator
   
 
       
   

1.14 Conditionals

Conditionals testing one case:

if (a > 7) {
  ...
}
Conditionals testing one case with an alternative for otherwise:

if (j == 9) {
  ...
} else {
  ...
}
Conditionals for multiple tests:

if (b == 0) {
  ...
} else if (b == 1) {
  ...
} else if ...
  ...
} else {
  ...
}
Equality tests can be aggregated using boolean operators:

if ((a == 1) && (b == 0)) {
  ...
}
or:

if (((a > 1) && (b == 0)) || (y == 7) {
  ...
}