// **********************************
// **函数名:isNumber
// **功 能:判断字符串是否只包含数字
// **参 数:String
// **返回值:boolean
// ***********************************
public boolean isNumber(String s) {
boolean bl = false;
s = "2244434245460KIP";
//匹配正整数
String str = null; //这里不会写了,请告诉我判断数字的正则表达式子 谢谢!!
Pattern p = Pattern.compile(str);
Matcher match = p.matcher(s);
if (match.find()) {
return !bl;
} else {
return bl;
}
}

解决方案 »

  1.   


    public static void main(String[] args) {
    String s = "24443424546";
    String str = "[a-zA-Z]+";
    Pattern p = Pattern.compile(str);
    Matcher match = p.matcher(s);
    if (match.find()) {
    System.out.println("Not Number");
    } else {
    System.out.println("Number");
    }
    }
      

  2.   

    public boolean isNumber(String s) {
            boolean bl = false;
            s = "2244434245460KIP";
            //匹配正整数
            String str = "\\d+"        Pattern p = Pattern.compile(str);
            Matcher match = p.matcher(s);
            if (match.find()) {
                return !bl;
            } else {
                return bl;
            }
        }
      

  3.   

    public boolean isNumber(String s) { 
            boolean bl = false; 
            s = "2244434245460KIP"; 
            //匹配正整数 
            String str = "\\d+" ;       
           Pattern p = Pattern.compile(str); 
            Matcher match = p.matcher(s); 
            if (match.find()) { 
                return !bl; 
            } else { 
                return bl; 
            } 
        } 
      

  4.   

    没测过吧 只要有数字都为true的。数字字母组合也true。
      

  5.   

    正则表达式可以实现的,建议楼主Google一下,系统的学一下,不要为了解决问题而解决问题
      

  6.   

    public class A{
        public static void main(String[] args){
            String  s = "2244434245460KIP";
            boolean bl=Pattern.matches("\\b+",s);
            if(bl){
               System.out.println("您输入的字符串只包含数字");
            }
            else{
                System.out.println("您输入的字符串不是只包含数字");
            }
        }
    }