thread “main” java.lang.NumberFormatException: null

后端 未结 2 476
礼貌的吻别
礼貌的吻别 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.

    0 讨论(0)
  • 2021-01-29 16:48

    That exception means that when you are executing this line of code

    id1 = Integer.valueOf(id).intValue();

    the value you are trying to convert into an integer (id), isn't a number.

    You need to double check your input file's format.

    0 讨论(0)
提交回复
热议问题