码迷,mamicode.com
首页 > 编程语言 > 详细

数组合并--Java原生方法

时间:2020-01-10 20:13:42      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:near   static   one   throw   com   code   combine   sse   public   

废话不多说,直接上代码(工具类):

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原生方法

标签:near   static   one   throw   com   code   combine   sse   public   

原文地址:https://www.cnblogs.com/javamjh/p/12177858.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!