How do I convert Double[] to double[]?

后端 未结 8 1755
没有蜡笔的小新
没有蜡笔的小新 2020-11-28 09:04

I\'m implementing an interface that has functionality similar to a table that can contain an types of objects. The interface specifies the following function:



        
8条回答
  •  一向
    一向 (楼主)
    2020-11-28 09:40

    In Java 8, this is one-liner:

    Double[] boxed = new Double[] { 1.0, 2.0, 3.0 };
    double[] unboxed = Stream.of(boxed).mapToDouble(Double::doubleValue).toArray();
    

    Note that this still iterates over the original array and creates a new one.

提交回复
热议问题