title: How to call abstract methods from an ArrayList traversing objects?
body: <p>I am trying to use a loop to traverse an Arraylist of objects, but when I call abstract methods to be printed I get the symbol cannot be found error For example:</p>
  
  <pre><code>ArrayList&lt;Shape&gt; al = new ArrayList&lt;Shape&gt;();
      Shape triangle = new Triangle(3.0, 2.5, 2.0);
      Shape rectangle = new Rectangle(2.0, 4.0);
      Shape circle = new Circle(1.0);
      al.add(triangle);
      al.add(rectangle);
      al.add(circle);
      for(int i = 0; i &lt; al.size(); i++)
      {
          System.out.println(al.get(i), al.calculateArea(), al.calculatePerimeter(), al.toString());
      }
   }
  </code></pre>
  
  <p>Full rectangle class</p>
  
  <pre><code>public class Rectangle extends Shape
  {
  
      private double length, width;
  
      public Rectangle(double length, double width)
      {
          double length1 = length;
          double width1 = width;
      }
  
      public double calculateArea()
      {
         double rectangleArea = length * width;
         return rectangleArea;
      }
  
      public double calculatePerimeter()
      {
          double rectanglePerimeter = (length * 2) + (width * 2);
          return rectanglePerimeter;
      }
  
      public String toString()
      {
          // put your code here
          return super.toString() + "[length=" + length + "width=" + width + "]";
      }
  </code></pre>
  
  <p>toString() and get(i) seem to work fine, but in calling the abstract methods implemented in triangle, circle etc subclasses the symbol error comes up. I tried overriding these methods in the subclasses but I get the same error.</p>