[java] Two constructors

As I remember I can use first constuctor in second constuctor, but there is mistake on bold line, could you help me to correct it?

  public FaceExtAdditionCanvas() {     profileImage.setSize(IMAGE_WIDTH, IMAGE_HEIGHT);     add(profileImage, getWidth() / 2.0 - IMAGE_WIDTH / 2.0, IMAGE_MARGIN);   }    public FaceExtAdditionCanvas(GImage image){     profileImage=image;     **this.FaceExtAdditionCanvas();**   } 

This question is related to java constructor

The answer is


To call one constructor from another you need to use this() and you need to put it first. In your case the default constructor needs to call the one which takes an argument, not the other ways around.


The first line of a constructor is always an invocation to another constructor. You can choose between calling a constructor from the same class with "this(...)" or a constructor from the parent clas with "super(...)". If you don't include either, the compiler includes this line for you: super();