是否有内置的Java方法来装箱阵列? [英] Is there a built-in Java method to box an array?

查看:120
本文介绍了是否有内置的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.

这篇关于是否有内置的Java方法来装箱阵列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆