Copy contents of an int array to a double array in Java?

前端 未结 4 1519
无人及你
无人及你 2021-01-04 20:35

I\'m trying to copy the contents of my int array into an array of type double. Do I have to cast them first?

I successfully copied an array of type int to another a

4条回答
  •  离开以前
    2021-01-04 21:15

    System.arraycopy() can't copy int[] to double[]

    How about using google guava:

    int[] a = {23,31,11,9};
    
    //copy int[] to double[]
    double[] y=Doubles.toArray(Ints.asList(a));
    

提交回复
热议问题