title: Java: cannot reference height before supertype constructor has been called
body: <p>I'm trying to create a class Figure with subclasses like rectangle, triangle and circle. However, when I try to compile them I get the same error in all of them, which makes me believe that the error is in the Figure class. The error: cannot reference height before supertype constructor has been called.</p>
  
  <p>Figure:</p>
  
  <pre><code>public abstract class Figure{
      public double width;
      public double height;
  
      public Figure(double width, double height){
          this.width = width;
          this.height = height;
      }
  
      public abstract double area();
  
      public abstract double perimeter();
  }
  </code></pre>
  
  <p>Ellipse:</p>
  
  <pre><code>public class Ellipse extends Figure{
      private double a;
      private double b;
  
      public Ellipse(){
          a = width/2;
          b = height/2;
      }
  
      public double area(){
          return (Math.PI * a * b);
      }
  
      public double perimeter(){
          return (2 * Math.PI * Math.sqrt((Math.pow(a,2) + Math.pow(b,2)))/2);
      }
  
  }
  </code></pre>
  
  <p>Thank you very much.</p>