记录一个方法,用来判断一个字串中字符是否全为字母
public class MainClass {
public static void main(String[] args){
String str = "hhhggdxszfff";
boolean is_boolean = isPhonticName(str);
System.out.println(is_boolean);
}
public static boolean isPhonticName(String str) {
char[] chars=str.toCharArray();
boolean isPhontic = false;
for(int i = 0; i < chars.length; i++) {
isPhontic = (chars[i] >= 'a' && chars[i] <= 'z') || (chars[i] >= 'A' && chars[i] <= 'Z');
if (!isPhontic) {
return false;
}
}
return true;
}
}
java 判断一个字串中的字符全是字母
最新推荐文章于 2024-07-29 14:22:26 发布