我一直在这个挠我的头一阵子..不知道该怎么办。Nullpointerexception当使用parseDouble
String tempprice = null;
String findPriceCommand = "SELECT sellingprice FROM `item` WHERE itemNo = '" + itemNo + "'";
try
{
tempprice = viewValue(conn, findPriceCommand);
}
catch (SQLException e)
{
e.printStackTrace();
}
Double price = Double.parseDouble(tempprice);
Double temp = (quantity.get(count) * price);
finalprice.add(temp);
的所有IM试图做到这一点得到通过货号数据库的价格。由于即时获得这个值作为一个字符串值,我使用Double price = Double.parseDouble(tempprice);
将其更改为一个双值。 这一切工作,我转身前finalprice
到ArrayList
(这样我可以同时插入多个值。(上面给出的代码是一个循环...的一部分)反正现在即时得到一个NullPointerException
就像这样:
int count = 0;
if (action.getSource() == btnAdd)
{
//other ArrayList variables
ArrayList<Integer> quantity = new ArrayList<Integer>();
ArrayList<Double> finalprice = new ArrayList<Double>();
//.....previous code...
count++;
}
任何线索什么,我在这里失踪?/
tempprice为null,这就是为什么你得到一个NullPointerException – ryekayo 2014-11-03 19:48:40
代码中的循环在哪里? – manouti 2014-11-03 19:50:36
您需要开始使用调试器 – Lovis 2014-11-03 19:50:42