数组合并--Java原生方法
Posted Daydrea_M_ENG
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数组合并--Java原生方法相关的知识,希望对你有一定的参考价值。
废话不多说,直接上代码(工具类):
public static Object[] combineArray(Object one[], Object two[]) throws BussinessException { Object res[] = null; if(one != null && one.length > 0 && (two == null || two.length == 0)) { res = new Object[one.length]; System.arraycopy(one, 0, res, 0, one.length); } if((one == null || one.length == 0) && two != null && two.length > 0) { res = new Object[two.length]; System.arraycopy(two, 0, res, 0, two.length); } if(two != null && one != null && two.length > 0 && one.length > 0) { res = new Object[two.length + one.length]; System.arraycopy(two, 0, res, 0, two.length); System.arraycopy(one, 0, res, two.length, one.length); } return res; }
以上是关于数组合并--Java原生方法的主要内容,如果未能解决你的问题,请参考以下文章