M
Matt
I have a method to return a String depending on the random number
public String getResponseType()
{
Random r = new Random();
int n = r.nextInt();
n = Math.abs(n);
n = n % 3;
switch(n)
{ case 0: return "EXACTMATCH";
case 1: return "RANGEMATCH";
case 2: return "ALTMATCH";
}
return "";
}
If I omit line return "", it will have compile error "This method must
return the result of type String"
I feel uncomforable with the line return ""; because this line is
always unreachable, but if
I omit this, I will have compile error.
Please advise. thanks!!
public String getResponseType()
{
Random r = new Random();
int n = r.nextInt();
n = Math.abs(n);
n = n % 3;
switch(n)
{ case 0: return "EXACTMATCH";
case 1: return "RANGEMATCH";
case 2: return "ALTMATCH";
}
return "";
}
If I omit line return "", it will have compile error "This method must
return the result of type String"
I feel uncomforable with the line return ""; because this line is
always unreachable, but if
I omit this, I will have compile error.
Please advise. thanks!!