public Map getSecondMap(Long id) {
Map<Long, String> secondMap=null;
FirstOutfit first=this.getFirstOutfitDao().findById(id);
Iterator it=first.getSecondOutfits().iterator();
while(it.hasNext()){
SecondOutfit second=(SecondOutfit)it.next();
Long secondId=second.getSecondOutfitId();//System.out.println()能正常打出来
String secondName=second.getSecondOutfitName();//System.out.println()能正常打出来
secondMap.put(secondId, secondName);
}
System.out.println("secondMapsize is:"+secondMap.size());//这句话不执行就报异常了 空指针异常
return secondMap;
}
代码如上:现在的问题是secondMap里面加不进东西去,报空指针异常..我实在整不明白咋回事了,请大家帮忙看看,谢谢....