You can't compare actual strings with >
or <
. What you actually want to compare in your case is the number contained in the string, not the string itself.
For that, your constants should probably be stored as int
:
static final int LOWER_VOL= 99;
static final int UPPER_VOL= 351;
And before comparison, your strInput
should be converted to int
aswell. Something like this:
int inputValue = Integer.parseInt(strInput); // parsing exceptions to be handled here
if(inputValue > lowervol && inputValue < uppervol) {
// do stuff
}
When adapting the naming convention of the constants from above, the final snippet will look like this:
int inputValue = Integer.parseInt(strInput); // parsing exceptions to be handled here
if(inputValue > LOWER_VOL && inputValue < UPPER_VOL) {
// do stuff
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…