3089589

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

public static Object arrayGrow(Object obj,int addlength){
        Class c = obj.getClass();
if(!c.isArray()){
return null;
        }
        Class type = c.getComponentType();
int length = Array.getLength(obj);
int newlength = length+addlength;
        Object newArray = Array.newInstance(type, newlength);
        System.arraycopy(obj, 0, newArray, 0, length);
return newArray;
    }
posted on 2013-03-26 09:24  liangge0218  阅读(157)  评论(0编辑  收藏  举报