在项目中通过String s=map.get(key);
得到s=""或者s=null
然后用Integer.parseInt(s)转化的时候却发现Integer.parseInt(s)无显示,也无报错信息;查了下API,里面没有给出String为null或者为""的返回值和异常...
非常郁闷中.....大家帮我解释下到底什么原因
得到s=""或者s=null
然后用Integer.parseInt(s)转化的时候却发现Integer.parseInt(s)无显示,也无报错信息;查了下API,里面没有给出String为null或者为""的返回值和异常...
非常郁闷中.....大家帮我解释下到底什么原因
没有反应
代码执行到那儿了吗? debug看看
throws NumberFormatException将字符串参数作为有符号的十进制整数进行解析。除了第一个字符可以是用来表示负值的 ASCII 减号 '-' ('\u002D') 外,字符串中的字符都必须是十进制数字。返回得到的整数值,就好像将该参数和基数 10 作为参数赋予 parseInt(java.lang.String, int) 方法一样。 参数:
s - 包含要解析的 int 表示形式的 String。
返回:
用十进制参数表示的整数值。
抛出:
NumberFormatException - 如果字符串不包含可解析的整数。
throws NumberFormatException
Parses the string argument as a signed decimal integer. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' ('\u002D') to indicate a negative value. The resulting integer value is returned, exactly as if the argument and the radix 10 were given as arguments to the parseInt(java.lang.String, int) method. Parameters:
s - a String containing the int representation to be parsed
Returns:
the integer value represented by the argument in decimal.
Throws:
NumberFormatException - if the string does not contain a parsable integer.
你查的哪个API啊?????怎么可能没给出、、、、、、、、
还有用的什么编译器,是不是它报错了你没发现、、、、、、
这里是通过xml字符串解析得来的,里面有个节点就是<key></key>,中间是没有值的
”吧
Map接口中包含的“破坏性”方法可修改其所操作的映射,如果此映射不支持该操作,则指定这些方法抛出 UnsupportedOperationException。如果是这样,那么在调用对该映射无效时,这些方法可能,但并不一定抛出 UnsupportedOperationException。例如,如果某个不可修改的映射(其映射关系是“重叠”的)为空,则对该映射调用 putAll(Map) 方法时,可能但并不一定抛出异常在API上面找的...
String string="";
System.out.println(Integer.parseInt(string));Exception in thread "main" java.lang.NumberFormatException: For input string: ""
String string=null;
System.out.println(Integer.parseInt(string));Exception in thread "main" java.lang.NumberFormatException: null