[英]How to populate a hashmap with the keys in one set and the values in another set
我正在使用Property對象,並且具有以下內容:
m_Properties.stringPropertyNames() //A set of Strings that I want to use as the key
m_Properties.values() //A set of Strings that I want to use as the value
我想把它們放在這個哈希圖中
private static HashMap<String, String> newProperties = new HashMap<String, String>();
我不確定是否必須同時遍歷這兩個方法,但是我該怎么做呢?
丑陋的古代物體。
for(String property : m_Properties.stringPropertyNames()) {
newProperties.put(property, m_properties.getProperty(property));
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.