How to cast from List to double[] in Java?

前端 未结 7 536
野性不改
野性不改 2020-11-28 13:18

I have a variable like that:

List frameList =  new ArrayList();

/* Double elements has added to frameList */

H

7条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-28 13:49

    Guava has a method to do this for you: double[] Doubles.toArray(Collection)

    This isn't necessarily going to be any faster than just looping through the Collection and adding each Double object to the array, but it's a lot less for you to write.

提交回复
热议问题