public class Middle {
  /**
   * Return the value that would be in the middle
   * if a, b, and c were sorted.
   */
  public static int middle(int a, int b, int c) {
    // If b and c are out of order, swap them.
    if (b > c) {
      // We declare local variables as close as possible to their
      // first use to improve readability.
      int temp= b;
      b= c;
      c= temp;
    }

    // The variable temp is not visible here, because its scope is
    // limited to the if block in which it was declared.

    assert b <= c;
    if (a <= b) {
      assert a <= b && b <= c;
      return b;
    }

    assert a > b && c > b;
    // The smaller of the two is in the middle.
    return Math.min(a, c);
  }
}
