java判断是否为数字

//采用正则表达式的方式来判断一个字符串是否为数字,这种方式判断面比较全  
        //可以判断正负、整数小数  
        //?:0或1个, *:0或多个, +:1或多个  
        Boolean strResult = str.matches("-?[0-9]+.*[0-9]*");  
          
if(strResult == true) {  
            System.out.println("Is Number!");  
        } else {  
            System.out.println("Is not Number!"); 

  

猜你喜欢

转载自www.cnblogs.com/SuKiWX/p/12923171.html