I have a switch case that checking if char is "=" or "-" or "+" but I like to check also if char is a number from 0-9
public static Token get(char ch) {
switch (ch) {
case '-' :
case '+':
case '=':
return new Token(ch);
case Character.isDigit(ch): // this dosn't work
{
}
}
}
what can I replace the Character.isDigit with?
You could define explicit
casestatements for the ten digit characters:Note here that we simply let all digit characters cases flow into a single point for handling.