1 18 19 package sync4j.framework.tools; 20 21 import java.lang.reflect.Array ; 22 23 24 30 public class ArrayUtils { 31 32 43 public static Object mergeArrays(Object [] a, Object [] b, Class elementType) { 44 45 int size = 0; 46 47 if (a != null) size += a.length; 48 if (b != null) size += b.length; 49 50 Object newArray = Array.newInstance(elementType, size); 51 52 int newArrayPos = 0; 53 if (a != null) { 54 System.arraycopy(a, 0, newArray, newArrayPos, a.length); 55 newArrayPos = a.length; 56 } 57 58 if (b != null) { 59 System.arraycopy(b, 0, newArray, newArrayPos, b.length); 60 } 61 62 return newArray; 63 64 } 65 66 } | Popular Tags |