您的位置 首页 技术

java判断字符串是否是整型数字

代码示例: /** * 判断字符串是否为数字 */ public static boolean isNumeric(String str){ Pattern pattern = P…

代码示例:

/**     * 判断字符串是否为数字     */    public static boolean isNumeric(String str){         Pattern pattern = Pattern.compile("[0-9]*");         Matcher isNum = pattern.matcher(str);        return isNum.matches();       }

(免费视频教程推荐:java视频教程)

测试:

public static void main(String[] args) {String str = "11";String str1 = "11sdf";System.out.println(isNumeric(str));System.out.println(isNumeric(str1));}

输出结果:

truefalse

相关文章教程推荐:java入门教程

以上就是java判断字符串是否是整型数字的详细内容,更多请关注24课堂在线网其它相关文章!

本文来自网络,不代表24小时课堂在线立场,转载请注明出处:https://www.24ketang.cn/32458.html

为您推荐

返回顶部