最近在编写android程序
源码是这样的:
child5 = new ArrayList>();
childData5 = new HashMap();
childData5.put("health_person_txt_smoking", person.getFlag_smoking());// 同理
childData5.put("health_person_txt_smokingnum", smokingnum);// 同理
childData5.put("health_person_txt_drink", person.getFlag_drink());
childData5.put("health_person_txt_drinknum", drinknum);
childData5.put("health_person_txt_training", person.getFlag_training());// 同理
childData5.put("health_person_txt_trainingnum", trainingnum);// 同理
childData5.put("health_person_txt_sleep", person.getFlag_sleep());
childData5.put("health_person_txt_sleepnum", sleepnum);
child5.add(childData5);
在下面直接编写map.get(key).tostring空指针异常。。。
//这样直接写get(key).toString();出现空指针异常该如何编写这段代码
String name=(String)childData1.get(health_person_txt_name).toString();
String sex=(String)childData1.get(health_person_txt_sex).toString();
String birthday_string=(String)childData1.get(health_person_txt_birthday).toString();
String blood=(String)childData1.get(health_person_txt_blood).toString();
String insurance=(String)childData1.get(health_person_txt_insurance).toString();
正确的编写方式什么???求各位老师帮忙解答