A part of a small program I am coding:
String maxs = "";
int maxi = 0;
At this part I defined two variables as int
and String
.
public Class(String max){
try {
this.maxi = Integer.parseInt(max);
}catch (Exception e){
this.maxs = max;
}
}
I think this way I will get to define one of both variables, if the String does not parse to int it will be saved as normal String.
Now I need to check what I need to return:
private TypeOfReturn getMax(){
if(this.maxi == 0){
// return maxs (return String)
} else if (this.maxs.equals("")) {
// return maxi (return int)
} else return null;
}
The quastion is, how do I fill the missing parts of the method getMax()
?
Is it even possiable in Java?