【发布时间】:2014-04-07 02:00:34
【问题描述】:
我是 Java 初学者 .. & 我不断收到这个错误 .. java.lang.NullPointerException 指向这一行 --> Double hOption = healthBenDesig.get("employeeOnly"); 有人可以告诉我我是否遗漏了什么或者我到底做错了什么?
private HashMap<String, Double> healthBenDesig;
public VariableList()
{
HashMap<String, Double> healthBenDesig = new HashMap<String, Double>();
}
public VariableList()
{
HashMap<String, Double> healthBenDesig = new HashMap<String, Double>();
}
public void getHMP()
{
Double hOption = healthBenDesig.get("employeeOnly");
System.out.println("The health Option you chose is: " + hOption);
}
public HashMap setHealthOpt()
{
healthBenDesig.put("none", 0.00);
healthBenDesig.put("employeeOnly", 311.87);
healthBenDesig.put("spouse", 592.56);
healthBenDesig.put("children", 717.30);
healthBenDesig.put("kids", 882.60);
System.out.println(healthBenDesig);
return healthBenDesig;
}
【问题讨论】:
标签: java