Why am I getting this error for “this(10)” even if the first statement is a constructor call. I am using eclipse.
public class MaxIndependentSet {
private ArrayList<Integer> inputArr = new ArrayList<Integer>();
public void MaxIndependentSet(int size) {
inputArr.ensureCapacity(size);
}
public void MaxIndependentSet() {
this(10);
}
}
You’ve added an incorrect return type
voidinto your constructor.The return type of a constructor is its class type, and it is declared implicitly, like so: