当hashMap的key是多个字段且想得到多个value时可能将key和 value分别做成List
view plaincopy to clipboardprint?
import javautilMap;
//inquiry result
List fromDetailList = instHdDaoretrieveInstInfoByView(sysOwnerCd fromCd instruct);
// Initial Value
Integer dtTotalTruck = ;
Integer dtTotalQuantity = ;
Map hm = new HashMap();
Iterator it = erator();
while(ithasNext()){
MeInstHd meInstHd = (MeInstHd)itnext();
List arr = new ArrayList();
List arr = new ArrayList();
List arr = new ArrayList();
String carrierCd = meInstHdgetCarrCd()trim();
arradd(carrierCd); // put keyValue to Arr
if(ntainsKey(arr)){
// carrierCd is exist in hm
arr = (ArrayList)hmget(arr); // 通过Key arr取得arr的Value arrList arr中有2列值他们分别是dtTotalQuantity 和dtTotalTruck
dtTotalQuantity = (Integer)arrget() ;
dtTotalQuantity += meInstHdsumInstructQty();
dtTotalTruck = (Integer)arrget() ;
dtTotalTruck += ;
arradd(dtTotalQuantity);
arradd(dtTotalTruck);
hmput(arr arr); // creat hashMap hm
}
else{
// carrierCd is not exist in hm
arradd(meInstHdsumInstructQty()); //put value to arr
arradd(); // dtTotalTruck initial value is
hmput(arrarr); // 其中arr是keyarr是value可以通过get(arr)来取得其value
}
}