str = "7667";
int = num;
try {
num = Integer.parseInt(str);
if (num<=0||num>29799966){
System.out.println("在指定范围内");
}
} catch (NumberFormatException e) {}
if (str.equals("")){
System.out.println("字符串为空");
}
3、判断String里是否有字母或数字加字母(注:若你有判断字符串里数字大小,建议将这个放下下面)
str = "d6sa7dja9"
if (str.matches("[0-9a-zA-Z]*")){
System.out.println("有字母和数字");
}
4、判断字符串里是否包含文字或字符
str = "jdoa加油";
Pattern p = Pattern.compile("[\u4E00-\u9FA5|\\!|\\,|\\。|\\(|\\)|\\《|\\》|\\“|\\”|\\?|\\:|\\;|\\【|\\】]");
Matcher m = p.matcher(str);
f (!m.find()){
System.out.println("有汉字和字符");
}