我已经阅读了csv并将值存储在map中(键值格式)我需要将2个特定键的所有值提取到数组列表中,以与数据库值列进行比较ArrayList ftlVal = new ArrayList (); for (Map<String, String> map : finResult) { Object[] key = {"Column2", "Column6"}; for (int i = 0; i < key.length; i++) { do { //for (int j = 0; j <key.length; j++) { //while (map.get(key[j]) != null) { Object value = map.get(key[i]); // System.out.println(value); if (!ftlVal.contains(value)) { ftlVal.add((String) value); System.out.println(ftlVal); i++; } }while (map.containsKey(key[i])); } } // System.out.println(finResult); //} //}我需要在清单中添加column2和column6的所有值,然后将这些列与数据库column2和column6进行比较 (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 除了将ArrayList与数据库列进行比较之外,以下代码将为您提供所需的两个ArrayList。ArrayList<String> column2List = new ArrayList<>();ArrayList<String> column6List = new ArrayList<>();for (Map<String, String> map : finResult) { String column2Value = map.get("Column2", null); String column6Value = map.get("Column6", null); column2List.add(column2Value); column6List.add(column6Value);}column2List和column6List是您需要的两个ArrayList。 (adsbygoogle = window.adsbygoogle || []).push({});
10-07 19:04
查看更多