<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">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 &gt; 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 &lt;= c;
    if (a &lt;= b) {
      assert a &lt;= b &amp;&amp; b &lt;= c;
      return b;
    }

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