In a Java Map <Integer, Double[]>, do I need to put the Double[] after getting and modifying?

Viewed 5914

A quick question which maybe is lame.

In the following code:

Map<Integer, Double[]> dataMap = new Map<Integer, Double[]>();
dataMap.put(1, new Double[]{100,100});
Double[] dob = dataMap.get(1);
dob[0] = 100;
dob[1] = 200;
dataMap.put(1, dob);

Is the last "dataMap.put" instruction necessary? or will the dataMap.get(1) yield a reference to the array which will then be modified directly in the later statements.

I know that, in the case of mutable objects (e.g. Map), Map.get() will give me the reference to the desired object, however with an array of Doubles (whose element type e.g. Double are immutable) I am not sure if I get a reference to the array in the Map.

Thanks!

2 Answers
Related