title: Write a method that returns the largest object in an array of objects
body: <p>Write a method that returns the largest object in an array of objects. The method signature is:</p>
  
  <pre><code>public static Object max(java.lang.Comparable[] a)
  </code></pre>
  
  <p>All the objects are instances of the <code>java.lang.Comparable</code> interface. The order of the objects in the array is determined using the <code>compareTo</code> method.</p>
  
  <p>Write a test program in the main method that creates an array of ten Strings, an array of ten Integers, and an array of ten <code>java.util.Dates</code>, and finds the largest <code>String</code> (i.e. in the alphabetical order), <code>Integer</code>, and <code>Date</code> in the arrays.</p>
  
  <p>Name your java class Max and your java file Max.java.</p>
  
  <p>I am having a hard time grasping what exactly I need to do in this assignment. The two things I am really struggling with is how to use an interface and the <code>compareTo</code> method. To my understanding interfaces only hold methods then I would have to call the <code>compareTo</code> method outside of the interface? Anyway this is what I have so far.</p>
  
  <pre><code>public class Max {
      public static Object max(java.lang.Comparable[] a) {
  
          Object tempObj = new Object();
  
          for (int i = 0; i &lt; a.length - 1; i++) {
              if ((a[i]).compareTo(a[i + 1]) &gt; 0)
                  tempObj = a[i];
              else
                  tempObj = a[i + 1];
          }
  
          return tempObj;
      }
  
      // compare toMethod
      public void CompareTo() {
          a[i].compareTo(a[i + 1]);
      }
  }// End Main
  
  class MaxTest implements Max {
      public void main(String[] args) {
  
          Integer[] intArray = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
          String[] stringArray = { "a", "b", "c", "d", "e", "f", "g", "h", "i",
              "j" };
          java.util.Date[] dateArray = {};
  
          for (int j = 0; j &lt; 10; j++)
              dateArray[j] = new java.util.Date();
  
      }// End Main
  }//End Class
  </code></pre>