我正在尝试用新的学生值更新 HashMap
,请检查我遗漏了什么。
ArrayList<Student> tempStudentList = XMLParser.studentHashMap.get(currentSectionName);
if(studentList==null)
{
Log.v(CURRENT_SCREEN,"created another student list for section name:"+currentSectionName);
tempStudentList = new ArrayList<Student>();
}
Log.v(CURRENT_SCREEN,"Added student to the list");
tempStudentList.add(currentStudent);
XMLParser.studentHashMap.put(currentSectionName, tempStudentList);
最佳答案
我想你想在 null 检查时写 tempStudentList
而不是 studentList
。
关于android - HashMap 访问同一个 ArrayList,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6330461/