图像格式大汇总区别介绍 各图像格
639 2023-04-03 02:27:14
package com.walker;import java.util.regex.Matcher;import java.util.regex.Pattern;public class Tester { public static void main(String[] args) { String str = "123"; //true System.out.println(isNumeric(str)); str = "-123"; //true System.out.println(isNumeric(str)); str = "abc"; //false System.out.println(isNumeric(str)); } //@ author: walker //用正则表达式判断字符串是否为数字(含负数) public static boolean isNumeric(String str) { String regEx = "^-?[0-9]+$"; Pattern pat = Pattern.compile(regEx); Matcher mat = pat.matcher(str); if (mat.find()) { return true; } else { return false; } }}
*** walker ***