title: Trying to swap the maximum and the minimum numbers in an array
body: <p>I'm trying to swap the maximum and minimum values in an array in my program.
  Here is the code:</p>
  <pre class="lang-java prettyprint-override"><code>public static void main(String[] args) {
      Scanner in = new Scanner(System.in);
  
      int myArray[] = new int[25];
  
      for (int i = 0; i &lt; myArray.length; i++) {
          System.out.println(&quot;Enter a number: &quot;);
          myArray[i] = in.nextInt();
      }
      int maximum = maxNumber(myArray);
      int minimum = minNumber(myArray);
  
      System.out.println(Arrays.toString(myArray));
  }
  </code></pre>
  <pre class="lang-java prettyprint-override"><code>public static int maxNumber(int[] arr) {
      int maximumValue = arr[0];
      //finds the maximum value in an array
      for (int a = 1; a &lt; arr.length; a++) {
          if (arr[a] &gt; maximumValue) {
              maximumValue = arr[a];
          }
      }
      return maximumValue;
  }
  </code></pre>
  <pre class="lang-java prettyprint-override"><code>public static int minNumber(int[] arr) {
      int minimumValue = arr[0];
      //finds the minimum value in an array
      for (int a = 1; a &lt; arr.length; a++) {
          if (arr[a] &lt; minimumValue) {
              minimumValue = arr[a];
          }
      }
      return minimumValue;
  }
  </code></pre>
  <p>I have two separate functions to find the Maximum and Minimum values, but I'm stuck on the actual swapping of the values. The two functions work as I've used them for another program, but I'm not sure if they would work for this program.</p>
  <p>At first I was thinking of finding them by setting them equal to each other in some way, but that led to nothing.</p>
  <p>Any help would be appreciated.</p>