I got error in java.lang.NumberFormatException: For input string: “null”

后端 未结 2 2012
有刺的猬
有刺的猬 2021-01-28 16:57

i have error in edit cart item in my app.the error is : java.lang.NumberFormatException: For input string: \"null\".i thing error line interget.parseInt(\"\"

相关标签:
2条回答
  • 2021-01-28 17:34

    The java.lang.NumberFormatException comes when you try to parse a non-numeric String to any Number like Integer or Double.

    For example, if you try to convert "null" to an integer then you will get NumberFormatException.

    The error "Exception in thread "main" java.lang.NumberFormatException: For input string: "null" is specifically saying that the String you receive for parsing is not numeric.

    Please ensure v.getTag() is not null before parsing.

    String input = v.getTag();
    
    If( null != input ) 
    {
      int updatePos = Integer.parseInt("" + input);
    }
    
    0 讨论(0)
  • 2021-01-28 17:44

    check XML and ensure that all of your Views have this attribute: android:tag="someTag"

    <View
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:tag="someTag"/>
    
    0 讨论(0)
提交回复
热议问题