how to check for a Letter in J2ME from a char
IN J2SE we can use Character.isLetter(c)
I want to use this : if (Character.isLetter(c) && Character.isUpperCase(c)){}
and also else if(Character.isSpace(c))
IN JAVA MOBILE Platform Any way to use it??
Seeing as you can't use Character.isLetter(c)
, I would just emulate its functionally. I would do this by treating the character as a "number" by using its ASCII value .
public static boolean isLetter(char c) {
return (c > 64 && c < 91) || (c > 96 && c < 123);
}
//Not necessary but included anyways
public static boolean isUpperCase(char c) {
return c > 64 && c < 91;
}
public static boolean isSpace(char c) {
//Accounts for spaces and other "space-like" characters
return c == 32 || c == 12 || c == 13 || c == 14;
}
Edit: Thank you @Nate for the suggestions/corrections
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.