I have a final map which is initialized in the constructor. I am adding the data to map in loop in addData() method. Is there a good way to add data to final map instead of using loop? Is there any feature in guava?
class TestClass {
private final Map<K,v> map1;
public TestClass() {
map1 = Maps.newHashMap();
}
public void addData(Map<K,V> data) {
for(Entry<K,V> entry : data.entrySet()) {
map1.put(entry.getKey(), entry.getValue());
}
}
}