Java Merge arrays

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.