我没有从Hashmap获得第二个键值,它仅显示第一个键及其Arraylist值,我如何获得所有键和Arraylist值?
You can iterate the hash map and retrieve each key and value:
for (Map.Entry<String, ArrayList<fileModel>> entry : deviceBackUpFb.entrySet()) {
String key = entry.getKey();
ArrayList<fileModel> values = entry.getValue();
for (fileModel value : values) {
...
}
}
Hopefully I understand your question. Try this:
Iterator it = deviceBackUpFb.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = (Map.Entry)it.next();
System.out.println(pair.getKey() + " = " + pair.getValue());
}
And then do whatever you want with the values.
pair.getKey(); // String
pair.getValue(); //ArrayList<model>
for (Entry<String, ArrayList<fileModel>> entry : deviceBackUpFb.entrySet()){
System.out.println(entry.getKey() + " " + entry.getValue());
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.