java.lang.NumberFormatException: For input string: “null”

后端 未结 6 1300
独厮守ぢ
独厮守ぢ 2020-12-21 05:16

I\'m parsing a doc and I get the following error:

Exception in thread \"main\" java.lang.NumberFormatException: For input string: \"null\"
    at sun.misc.Fl         


        
6条回答
  •  执笔经年
    2020-12-21 06:05

    Based on your error, it is very possible your latValues[i].trim() displays the value "null". I'm able to replicate your problem here:-

    Float.valueOf("null");
    

    Here's the stacktrace:-

    java.lang.NumberFormatException: For input string: "null"
        at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1301)
        at java.lang.Float.valueOf(Float.java:375)
    

    In another word, the value you have is not null, but it contains the word "null".

    If you do Float.valueOf(null);, that actually gives you a NullPointerException, which is not what you have here.

提交回复
热议问题