我有一个哈希图。对象包含姓名、地址、电子邮件等信息。我能够迭代 HashMap 但无法从对象中获取值。这是我的代码,如果有人可以请告诉我一个正确的方法来做到这一点。
public void getData(){
// hashmap is records<key, Object>
// Object contains properties name, address, email
Iterator it = records.entrySet().iterator();
while(it.hasNext()){
Map.Entry entry = (Map.Entry) it.next();
Object key = entry.getKey();
Object val = entry.getValue();
// this gets me through hashmap
// how do I get name, address and email from object?
}
}