Answer the question
In order to leave comments, you need to log in
How to call one constructor from another with a final variable?
Hello.
I have a structure like this:
public class A{
private final String someString;
private Object[] array;
public A(int size){
if(size<0){
throw new Exception();
}
array=new Object[size];
someString="defaultString"
}
public A(int size, String someString){
if(size<0){
throw new Exception();
}
array=new Object[size];
this.someString = someString;
}
}
Answer the question
In order to leave comments, you need to log in
Well, yes, because it is necessary not to call a constructor with one parameter from a constructor with two parameters, but vice versa. And pass "defaultString" there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question