是否有内置的Java方法来装箱阵列?
问题描述:
我是否可以使用标准方法代替此自定义方法?
Is there a standard method I can use in place of this custom method?
public static Byte[] box(byte[] byteArray) {
Byte[] box = new Byte[byteArray.length];
for (int i = 0; i < box.length; i++) {
box[i] = byteArray[i];
}
return box;
}
答
不,没有这样的JDK中的方法。
No, there is no such method in the JDK.
然而,通常情况下, Apache Commons Lang 提供这样的方法。
As it's often the case, however, Apache Commons Lang provides such a method.