How can I convert Map
to Map
?
This does not work:
Map map = ne
If your Objects
are containing of Strings
only, then you can do it like this:
Map map = new HashMap(); //Object is containing String
Map newMap =new HashMap();
for (Map.Entry entry : map.entrySet()) {
if(entry.getValue() instanceof String){
newMap.put(entry.getKey(), (String) entry.getValue());
}
}
If every Objects
are not String
then you can replace (String) entry.getValue()
into entry.getValue().toString()
.