一旦您关联将格式错误的字符串变量转换为彼此不兼容的整数(数字格式),就会发生此异常。
public class Test { public static void main(String[] args) { int data = Integer.parseInt("hello"); } }
输出结果
Exception in thread "main" java.lang.NumberFormatException: For input string: "hello" at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at a6.dateAndTime.Test.main(Test.java:5)