thread “main” java.lang.NumberFormatException: null

后端 未结 2 477
礼貌的吻别
礼貌的吻别 2021-01-29 16:14

I\'m a beginner to Java programming and I encounter the following exception:

Exception in thread \"main\" java.lang.NumberFormatException: null
            at ja         


        
2条回答
  •  别那么骄傲
    2021-01-29 16:47

    This exception occurs if you try to convert a string to a number, where the string does not actually contain a number.

    Example:

    Integer.valueOf("10").intValue(); works, but Integer.valueOf("abcd").intValue() throws out the NumberFormatException.

    Check your input file and make sure you're actually having a number there.

    Line by Line debugger would be very useful here. Also use the good old System.out.println to see the value in id.

提交回复
热议问题