title: Generics comparing objects in an ArrayList
body: <p>I'm trying to create a generic class that compares objects in an array list and returns the largest. My issue is that I'm not quite sure I understand completely how generics work. </p>
  
  <p>Measurable:</p>
  
  <pre><code>import java.util.ArrayList;
  
  /**
     Describes any class whose objects can be measured.
  */
  
  public abstract class Measurable&lt;T&gt;{
  
  abstract double getMeasure();
  
      public static &lt;T extends Measurable&lt;T&gt;&gt; T getLargest(ArrayList&lt;T&gt; objects){
          T largest = objects.get(0);
          for(int i = 0; i &lt; objects.size(); i ++){
              if(largest.getMeasure() == objects.get(i).getMeasure()){
                  largest = objects.get(i);
              }
          }
          return largest;     
      }
  
  }
  </code></pre>
  
  <p>Box:</p>
  
  <pre><code>import java.awt.Rectangle;
  import java.util.ArrayList;
  
  
  public class Box extends Measurable {
  
      private Rectangle box;
      private static ArrayList&lt;Rectangle&gt; rectangles;
  
      public Box(){
          box = new Rectangle();
          rectangles = new ArrayList&lt;Rectangle&gt;();
      }
  
      public ArrayList&lt;Rectangle&gt; create(){
          for(int i = 0; i &lt; 10; i++){
              box = new Rectangle((int) Math.random(), (int) Math.random());
              rectangles.add(box);
          }
          return rectangles;
      }
  
      @Override
      public double getMeasure() {
          double area = 0;
          for(int i = 0; i &lt; rectangles.size(); i++){
              area = rectangles.get(i).getWidth()*rectangles.get(i).getHeight();
          }
          return area;
      }
  
      public static void main(String[] args){
          Box b = new Box();
          b.getLargest(b.create());
      }
  }
  </code></pre>
  
  <p>I'm coming across an issue where it says "The method getLargest(ArrayList) in the type Measurable is not applicable for the arguments (ArrayList)" but shouldn't I be able to use any object for the getLargest class?</p>