I have this code
if(!(lotNo.charAt(0) >= "0" && (lotNo.charAt(0) <= "7"))) {
// if the first character is not within these boundaries
return false;
}
return true;
This method leaves me with an error saying bad operator type? Although it was supposed to check whether the first character in a String was between 0 and 7. Am I on the right lines?
You are comparing to strings instead of chars. Try:
"0"<– String with one char,'0''0'<– char, the character'0'