解决方案 »

  1.   


    我要做成两个list,一个是颜色,一个是尺码的。
      

  2.   


    我要做成两个list,一个是颜色,一个是尺码的。
    public static void main(String args[]) {
            Map<String, List<Map<String, String>>> resultMap = new HashMap<String, List<Map<String, String>>>();
            String color = "1627207:28338:yansefenlei:lanse";
            String[] arrColor = color.split(":");
            List<Map<String, String>> resultList = new ArrayList<Map<String, String>>();
            Map<String, String> map = new HashMap<String, String>();
            map.put(arrColor[3], arrColor[1]);
            resultList.add(map);
            resultMap.put(arrColor[0], resultList);
            List<Map<String, String>> list = resultMap.get("1627207");
            for (Map<String, String> mmap : list) {
                if (mmap.containsKey("lanse")) {
                    System.out.println("1627207" + ":" + mmap.get("lanse"));
                    break;
                }
            }
        }
      

  3.   


    我要做成两个list,一个是颜色,一个是尺码的。
    public static void main(String args[]) {
            Map<String, List<Map<String, String>>> resultMap = new HashMap<String, List<Map<String, String>>>();
            String color = "1627207:28338:yansefenlei:lanse";
            String[] arrColor = color.split(":");
            List<Map<String, String>> resultList = new ArrayList<Map<String, String>>();
            Map<String, String> map = new HashMap<String, String>();
            map.put(arrColor[3], arrColor[1]);
            resultList.add(map);
            resultMap.put(arrColor[0], resultList);
            List<Map<String, String>> list = resultMap.get("1627207");
            for (Map<String, String> mmap : list) {
                if (mmap.containsKey("lanse")) {
                    System.out.println("1627207" + ":" + mmap.get("lanse"));
                    break;
                }
            }
        }
    嗯很好,这样可以解决,非常感谢。我用了另外一种做法也解决了,我写了一个类Item,里面含有List<Item>这样也解决了我这个问题