The java.lang.NumberFormatException comes when you try to parse a non-numeric String to Number e.g. Short, Integer, Float, Double etc. 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 and it's true, "null" is not numeric. Many Java methods which convert String to numeric type e.g. Integer.parseInt() which convert String to int, Double.parseDoble() which convert String to double, and Long.parseLong() which convert String to long throws NumberFormatException to inform that the input String is not numeric.
Read more »
This comment has been removed by the author.
ReplyDeleteThis answer is helpful but this link sorted out my issue
ReplyDeletejava string to double