I am trying to overload a constructor in java. There are two Strings among its variables which is problematic if I write two separate constructors in the case of only one of these strings being called. This is why I would like to use the following code :
public Timbre(String string){
if(string.indexOf("-") == -1){
this, ANNEE_COURANTE, string, VALEUR_TIMBRE_DEFAUT);
} else{
this(string, ANNEE_COURANTE, PAYS_DEFAUT, VALEUR_TIMBRE_DEFAUT);
}
}
However, I am told by VSC that "Constructor call must be the first statement in a constructor". How can I overcome this problem?