My possibly naive solution for cloning an ArrayList (vector replacement)
ArrayList<Double> alBis = (ArrayList<Double>) alOriginal.clone();
given that since the array contains immutable pairs, I don't need to clone them, but only a container.
Since clone () returns the object, I put a throw there, but then -Xlint complains that this is an uncontrolled selection.
So what now? Ignore it with supressWarnings? Create a new ArrayList and copy the original elements with a compact? Any library method similar to Arrays.copyOf ()?
I am reading an Immediate Warning Warning , but the accepted method is incredibly complicated.
source
share