简体   繁体   English

在Java中将String转换为double时发生NullpointerException

[英]NullpointerException when converting String to double in java

I have an html form which contains a String which I need to convert into a double . 我有一个html表单,其中包含一个String ,我需要将其转换为double Then store it in an MS Access database. 然后将其存储在MS Access数据库中。 I tried using: 我尝试使用:

Double d = Double.parseDouble(String);

But it is throwing a NullpointerException. 但是它抛出了NullpointerException。 Can anyone explain why? 谁能解释为什么?

看一下API,发现如果参数为null ,则Double.parseDouble抛出NullPointerException

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM