title: Explanation on Integer.MAX_VALUE and Integer.MIN_VALUE to find min and max value in an array
body: <p>I don't seem to understand how <code>Integer.MAX_VALUE</code> and <code>Integer.MIN_VALUE</code> help in finding the min and max value in an array.</p>
  
  <p>I understand how this method (pseudocode below) works when finding the min and max values:</p>
  
  <pre class="lang-none prettyprint-override"><code>max = A[0], min = A[0]
  for each i in A
    if A[i] &gt; max then max = A[i]
    if A[i] &lt; min then min = A[i] 
  </code></pre>
  
  <p>But as for this method, I don't understand the purpose of <code>Integer.MAX_VALUE</code> and <code>Integer.MIN_VALUE</code>:</p>
  
  <pre><code>import java.util.Scanner;
  
  class MyClass {
  
      public static void main(String[] args) {
  
          int[] numbers; // declaring the data type of numbers
          numbers = new int[3]; //assigning the number of values numbers will contain
          int smallest = Integer.MAX_VALUE, largest = Integer.MIN_VALUE;
  
          Scanner input = new Scanner(System.in);
  
          System.out.println("Please enter 3 numbers");
  
          for(int counter = 0; counter&lt;numbers.length;counter++) {
              numbers[counter] = input.nextInt();
          }
  
          for(int i = 0; i&lt;numbers.length; i++) {
              if(numbers[i]&lt;smallest)
                  smallest = numbers[i];
              else if(numbers[i]&gt;largest)
                  largest = numbers[i];
          }
  
          System.out.println("Largest is "+largest);
          System.out.println("Smallest is "+smallest);
      }
  
  }
  </code></pre>
  
  <ul>
  <li>System.out.println(Integer.MAX_VALUE) gives 2147483647</li>
  <li>System.out.println(Integer.MIN_VALUE) gives -2147483648</li>
  </ul>
  
  <p>So what purpose do Integer.MIN_VALUE and Integer.MIN_VALUE serve in the comparisons?</p>