so my issue is that I have a class and its subclass.
-> class Kassenbon -> class KassenbonVerbessert extends Kassenbon
in my "Kassenbon" class I have this constructor:
public Kassenbon(int max) {
produkte = new String[max];
preise = new Integer[max];
}
and then the constructor of my subclass looks like this:
public KassenbonVerbessert(int max) {
super(max);
}
My issue now is that I want to check the parameter max and if it is negative then I wanna throw an exception because that would mean that the constructor would create 2 arrays with a negative length which isnt possible. But how do I do it simply because the super call must be the first statement in the constructor right?! But how do I implement a:
if(max < 0){
throw new IllegalArgumentException("Error");
}