I have a Java Map:
Map<String,String> mapThings = new HashMap<>();
updateMapThings(mapThings, sourceMap); // sourceMap is the original Map which has all the
// values I want to populate mapThings with.
So now mapTHings is like below
{
"a" : "A",
"b" : "B",
"c" : "C"
}
With a,A,b,B,c,C (all the key/values) populated from sourceMap
Now I want to populate mapThings with more key/values from sourceMap2, so mapThings will become like
{
"a" : "A",
"b" : "B",
"c" : "C",
"d" : "D",
"e" : "E",
"f" : "F"
}
where d,D,e,E,f,F are all key/values populated from sourceMap2.
Should I call
updateMapThings(mapThings, sourceMap2);
This is where I get confused whether Java is PassBy Value or Reference. How do I cleanly update the same map with different key/values from more than one source?