I have this line in my class:
public class Line extends Figure and when I compile with this command:
$ javac -cp :./stdlib.jar Line.java, I get this error:
Line.java:26: cannot find symbol
symbol : constructor Figure()
location: class Figure
public Line(double x0, double y0, double xn, double yn, Color initColor) {
-------------------------------------------------------------------------^
// the dashes above are supposed to be spaces, but I couldn't figure out how to format it correctly. The caret is actually there in that position
Normally I would understand this error, but this time I have no idea what is going on. I have the Figure.java file in the same directory as my Line.java.
The problem is there is no empty (default) constructor in Figure. Your Line has a constructor which takes several parameters. Line extends Figure. If you don’t call a specific constructor in the super class in the constructor for Line, Java will attempt to call the default (no param) constructor, but Figure doesn’t have one, so you get a compilation error.
In the constructor for Line, you’ll need something like: