android典型程式碼系列(十九)------將一個陣列複製成為另外一個陣列的方法

fandong12388發表於2015-12-04

將一個陣列複製成為另外一個陣列的方法 :

 private final <T> T[] copy(T[] source) {
        Class type = source.getClass().getComponentType();
        T[] target = (T[])Array.newInstance(type, source.length+1);
        System.arraycopy(source, 0, target, 0, source.length);
        return target;
     }

相關文章