📜  java 测试字符串是否为 int - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:11.160000             🧑  作者: Mango

代码示例1
public static boolean isInt(String str) {
    
      try {
          @SuppressWarnings("unused")
        int x = Integer.parseInt(str);
          return true; //String is an Integer
    } catch (NumberFormatException e) {
        return false; //String is not an Integer
    }
      
}