title: How to implement compareTo for any types of comparable objects
body: <p>I don’t know how I can compare 2 comparable objects without some other variable which tells me which is larger. The question is: Create a class called Max that provides a single class method called max. max takes two arguments to objects that can be compared—that is, that implement the Java Comparable interface as shown above. It returns a reference to whichever is larger. If the two objects are equal, you should return the first. How Comparable is implemented is up to each class, and your method will be called on multiple different kinds of objects.</p>
  
  <p>It gives the int compareTo (Object other) method in the interface but I’m having trouble finding a solution.</p>
  
  <pre><code>public class Max implements Comparable 
  {
      public int compareTo(Object other)
      {
  
      }
  
      public static Comparable max(Comparable first, Comparable second)
      {
          int fi = first.compareTo(second);
          if(fi &gt;0)
              return first;
          else if (fi&lt;0)
              return second;
          return first; 
      }
  }
  </code></pre>
  
  <blockquote>
    <p>java.lang.AssertionError: Class should not implement Comparable: expected [false] but found [true]</p>
  </blockquote>
  
  <p>That is one of the errors. But also I need help writing the compareTo method.</p>