Getting back primitive array after insertion into an ArrayList of primitive arrays in Java

后端 未结 4 1405
日久生厌
日久生厌 2020-12-18 17:42
List x = new ArrayList();
x.add(new double[]={1,2,3,4,54,6});  

elements 1,2,3,4,54,6 are added to x



        
4条回答
  •  Happy的楠姐
    2020-12-18 18:33

    double[] array is object. So, you get address and entire array is added at index 0.

    You may use Arrays.toString(x.get(0)) to get readable array print.

    toString() for an array is to print [, followed by a character representing the data type of the array's elements, followed by @ then the memory address.

提交回复
热议问题