Home Segments Top Top Previous Next

388: Mainline

Either the if-true statement or the if-false statement may be embedded if statements. Accordingly, another solution to the duration-testing problem looks like this:

public class Demonstrate { 
 public static void main (String argv[]) { 
  int length = 95; 
  if (length < 60) 
   System.out.println("It is short!"); 
  else 
   if (length > 90) 
    System.out.println("It is long!"); 
 } 
} 
--- Result --- 
It is long!