正在进行安全检测...

发布时间:1714485992   来源:文档文库   
字号:

java中判断字符串是否为数字的方法的几种方法
判断字符串是否为数字

//1、正则表达式
public static boolean isNumeric1(String str{
Pattern pattern = Pattern.compile("[0-9]*";
return pattern.matcher(str.matches(; } //2java自带函数
public static boolean isNumeric2(String str{
for (int i = str.length(;--i>=0;{
if (!Character.isDigit(str.charAt(i{ return false; }

} return true; } //3、正则表达式
public static boolean isNumeric(String str{ if(str.matches("\\d *"{ return true; }else{ return false; } } //4、判断ASCII码值
public static boolean isNumeric0(String str{

本文来源:https://www.2haoxitong.net/k/doc/8e934e9376c66137ee0619f9.html

《正在进行安全检测....doc》
将本文的Word文档下载到电脑,方便收藏和打印
推荐度:
点击下载文档

文档为doc格式

相关推荐