Flow Control
 
if (age == 28)
  {
  System.out.println("You are 28!");
  }
else if (age == 29)
  {
  System.out.println("You are 29!");
  }
else
  {
  System.out.println("You're neither!");
  }
while (x <=100)
  {
  X++
  System.out.println("x is: " x);
  }
// In a while loop, the action is 
// performed only if the test is true.  
// An interesting alternative is 
// the do / while loop that performs 
// the action "before" testing.
for (int x = 100;X >=0;x--)
  {
  System.out.println("x is: " x);
  }
Testing a Condition
 (8 > 2) && (2 == 3) // Returns false because // one is false (8 >= 2) || (2 == 3) // Returns true because // at least one is true. // Notice that the second // test is short circuited // by the true result in // the first.The Switch Statement 
 switch (input)
  {
  case 1;
    {
    System.out.println("You entered a 1");
    break;
    }
  case 2;
    {
    System.out.println("You entered a 2");
    break;
    }
  case 3;
    {
    System.out.println("You entered a 3");
    break;
    }
  }
 Thus, it would not be strange to see something like the following: switch(number)
  {
  case 1:
  do something;
  break;
  case 2
  do something;
  break;
  case 3
  do something;
  break; 
  default
  tell user to type in the correct number
  break
  }
Breaks
 Additional Resources:
 Table of Contents Object Orientation in Java  | 
| 
		Hosted by Graphics & Media Lab
	 http://graphics.cs.msu.su  | 
 | 
mailto: Laboratory |