利用IndexOf的命令来进行排查文本中是否含有数字。

public static boolean isNumeric(String str)
   {
       int result1 = str.indexOf("1");  
       int result2 = str.indexOf("2");  
       int result3 = str.indexOf("3");  
       int result4 = str.indexOf("4");  
       int result5 = str.indexOf("5");  
       int result6 = str.indexOf("6");  
       int result7 = str.indexOf("7");  
       int result8 = str.indexOf("8");  
       int result9 = str.indexOf("9");  
       int result10 = str.indexOf("0");  

       boolean shifou;

       if(result1 == -1&&result2 == -1&&result3 == -1&&result4 == -1&&result5 == -1&&result6 == -1&&result7 == -1&&result8 == -1&&result9 == -1&&result10 == -1)
       {
           shifou = true;
           return true;
       }
       else
       {
           return false;
       }
   }
Last modification:March 4th, 2019 at 09:38 am
If you think my article is useful to you, please feel free to appreciate