Java concatenates two arrays, and java concatenates two arrays.

Source: Internet
Author: User

Java concatenates two arrays, and java concatenates two arrays.

1 int a [] = {,}; 2 int B [] = {, 98}; 3 int [] d3 = new int [. length + B. length]; 4 System. arraycopy (a, 0, d3, 0,. length); 5 System. arraycopy (B, 0, d3,. length, B. length );

The parameter meaning of System. arraycopy: (src, srcPos, dest, destPos, length) -- (source array, source array start position, target array, target array start position, and copy length)


How to splice two java arrays into json strings:

... You can find a JSON conversion plug-in.
It is easy to merge arrays, and then use the JSON Conversion Tool class. frequently-used ins gson, fastjson, etc.
 
How to merge two int-type arrays in java?

Public class ContactIntegerArray {

Public static int [] contact (int a [], int B []) {
Int [] f = new int [a. length + B. length];
For (int I = 0; I <f. length; I ++)
If (I <a. length)
F [I] = a [I];
Else
F [I] = B [i-a.length];
Return f;
}

Public static void main (String [] args ){
Int a [] = {1, 3, 4, 7 };
Int B [] = {2, 3, 5 };

Int c [] = ContactIntegerArray. contact (a, B );

}

}

Related Article

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.