我想从 HashMap 中获取属性。
HashMap<String, Object> getProperties()
我想获得真实的属性。
例子:
HashMap<String, String> newMap = new HashMap<String, String>();
newMap.put("property", "shhh_secret");
String value = newMap.get("property");
或者
Set s = newMap.keySet();
for (Iterator iter = s.iterator(); iter.hasNext()) {
newMap.get(s);
}
或者
Iterator iter = newMap.keySet().iterator();
while (iter.hasNext()) {
...
}
Question which can help you :
How to Get Values from List of HashMap?
get string value from HashMap depending on key name
http://www.coderanch.com/t/407505/java/java/Retrieve-values-hashmap
这将有助于从 HashMap 中读取值。简单示例
HashMap<Integer, String> hm = new HashMap<Integer, String>();
hm.put(1, "One");
hm.put(2, "Two");
hm.put(3, "Three");
Set st = hm.entrySet(); //hm.keySet();
for(Iterator itr = st.iterator(); itr.hasNext();)
{
//hm.get(st);
System.out.println(itr.next());
}