I have a hash map and am trying to convert keys to a list. Here is the code:
List<ARecord> recs = new ArrayList<ARecord>(); HashMap<String, ARecord> uniqueRecs = new HashMap<String, ARecord>(); for(ARecord records:recs){ if(!uniqueRecs.containsKey(records.getId())){ uniqueRecs.put(records.getId(), records); } }
When i try to do
List<ARecord> finalRecs = new ArrayList<ARecord>(uniqueRecs.keySet());
Mistake:
The constructor of ArrayList (Set) is not defined. "
How can I convert Hashmap keys to List<ARecord> finalRecs?
java arraylist hashmap
Jay
source share