乐趣区

关于java:java开发中遇到的一些问题

1.HashMap 相干问题

1.1HashMap 存 key,value,key 会有反复的,value 会有多个值,选取此形式进行存取,动静获取 key,value 取 list,若满足条件,list 始终 add,key 笼罩掉之前的,list 始终在减少。

HashMap<String, List<ScatteredPrescriptionDetail>> preDetailMap=new HashMap<String, List<ScatteredPrescriptionDetail>>();
            for (int i=0;i<prescriptionDetailList.size();i++) {ScatteredPrescriptionDetail scatteredPrescriptionDetail = prescriptionDetailList.get(i);
                if("Y".equals(scatteredPrescriptionDetail.getIsSubOrder())){if (!preDetailMap.containsKey(scatteredPrescriptionDetail.getParentOrderSN())) {List<ScatteredPrescriptionDetail> tmpList=new ArrayList<ScatteredPrescriptionDetail>();
                        tmpList.add(scatteredPrescriptionDetail);
                        preDetailMap.put(scatteredPrescriptionDetail.getParentOrderSN(), tmpList);
                    }
                    else {System.out.println();
                        preDetailMap.get(scatteredPrescriptionDetail.getParentOrderSN()).add(scatteredPrescriptionDetail);
                    }
                }
                else if("N".equals(scatteredPrescriptionDetail.getIsSubOrder())){faList.add(scatteredPrescriptionDetail);
                }
            }
退出移动版