我正在使用 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
我想把它们放在这个 HashMap 中
private static HashMap<String, String> newProperties = new HashMap<String, String>();
我不确定,因为我必须同时遍历两者,但我该怎么做?
最佳答案
丑陋的古代物体....
for(String property : m_Properties.stringPropertyNames()) {
newProperties.put(property, m_properties.getProperty(property));
}
关于java - 如何使用一组中的键和另一组中的值填充 HashMap ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28774284/