title: Finding max/min value using Comparable
body: <p>I have an object class </p>
  
  <pre><code>public class Film implements Comparable&lt;Film&gt;
  </code></pre>
  
  <p>I'm using Eclipse and would like to know why <code>Film</code> is underlined in red with the error saying: </p>
  
  <p><code>The type Film must implement the inherited abstract method Comparable&lt;Film&gt;.compareTo&lt;Film&gt;</code></p>
  
  <p>And now to my main question:</p>
  
  <p><strong>How would I get the max/min user submitted film length and title?</strong></p>
  
  <p>My object class Film has getter and setter methods for the Title of the film and the Length of the film and a toString method. Following <a href="http://www.mkyong.com/java/java-object-sorting-example-comparable-and-comparator/" rel="nofollow">this</a> article (#3) I created two more methods in my object class:</p>
  
  <pre><code>public int max(Film maxLength){
      int compareLength = ((Film) maxLength).getLength();
  
      return this.length - compareLength;
  }
  
  public int min(Film minLength){
      int compareLength = ((Film) minLength).getLength();
  
      return compareLength - this.length;
  }
  </code></pre>
  
  <p>Could I use these to find and print max/min values of the user submitted film lengths? </p>
  
  <p>If so, how?</p>
  
  <p>If not, what is the proper way of doing this?</p>
  
  <p>The test class is as follows: </p>
  
  <pre><code>import java.util.Scanner;
  public class test {
      public static void main (String[] args){
          Film[] f = new Film[3];
          Scanner input = new Scanner(System.in);
          for (int i=0;i&lt;3;i++){
              f[i] = new Film(); 
  
              System.out.println("Enter Film Length:");
              f[i].setLength(input.nextInt());
              input.nextLine();
              System.out.println("Enter Title:");
              f[i].setTitle(input.nextLine());
          }
          input.close();
          for (int i = 0; i &lt; 3; i++) {
              System.out.println(f[i].toString());
          }
      }
  }
  </code></pre>