1 Packagedemo;2 3 Public classArrayCopy {4 Public Static voidMain (string[] args) {5String a[]=Newstring[]{"1", "2", "2"};6String b[]=Newstring[]{"3", "4", "5"};7 ArrayCopy (A, b);8 }9 Ten Public Static voidarrayCopy (string[] a,string[] b) { OneString[] C=Newstring[a.length+B.length]; ASystem.arraycopy (A, 0, C, 0, a.length); -System.arraycopy (b, 0, C, A.length, b.length); -System.out.println ("---------the merged array is:------------"); the for(String string:c) { -System.out.print (string+ ","); - } - } + -}
PS: The above example is a relatively simple implementation, with the System.arraycopy method can be. Another stupid way is to copy the array to consolidate, the efficiency is low, not written here.
In addition, the above example is only a combination of the array, not to be processed, the difference set of arrays, intersection, Union, please refer to my other article http://www.cnblogs.com/wanying521/p/5179151.html
Java Merge arrays