I know I can create an object this way
int[] list1 = {1, 2}; int[] list2 = list1.clone(); and this normally works. But why doesn't this work properly:
ArrayList<Double> list1 = new ArrayList<Double>(); list1.add(1.0); list1.add(2.0); list1.add(0.5); ArrayList<Double> list2 = list1.clone(); What I know is that this code is fine
ArrayList<Double> list2 = (ArrayList<Double>)list1.clone(); maybe because list1.clone() is doesn't return a reference type, so it needs (ArrayList) to make it return a reference type.
but why int[] list2 = list1.clone(); can work?