I have a map code in java.This is my following code.
Map<String, String> map = new HashMap<String, String>();
map.put("type", "One");
map.put("name", "Two");
map.put("setup", "Three");
System.out.println("Map Values Before: ");
Set<String> keys = map.keySet();
for (Iterator<String> i = keys.iterator(); i.hasNext();) {
String key = (String) i.next();
String value = (String) map.get(key);
Map<String, String> map = new HashMap<String, String>();
}
Here i am able to get the output.My problem is i need match each key values to separate strings for further use in my code.How to i can get each key value in separate strings.Please help me.
Taking a guess at your meaning, you want to populate variables corresponding to the keys
Now I assume that simple code such as
is unacceptable, or you surely would not ask the question, so you want some programmatic way of iterating the set of properties?
In which case look at the Reflection APIs.
Please confirm that this is the problem you’re trying to solve, and have a look at the APIs, if you then have specific questions follow up …