when you create a constructor for a class, there won’t be any default constructor created for that class. so if you extend that class and if the subclass tries to call the no-arg constructor of its super class then there will be an compile-time error.
to demonstrate:
class Parent {
int i;
public Parent(int i) {
this.i=i;
}
}
class Child extends Parent {
int j;
public Child(int i, int j) {
super(i);
this.j=j;
}
public Child(int j) {
// here a call to super() is made, but since there is no no-arg constructor
// for class Parent there will be a compile time error
this.j=j;
}
}
EDIT:
to answer your question do this, don’t assign the value arrLength
to arr[]
and check[]
as arrLength would be 0
at that time.
so just declare them like this
int arr[];
boolean check[];
and in the constructor after you assign the input to arrLength
put these statements.
arr = new int[arrLength];
check = new boolean [arrLength];