[Java] arraycopy array copy (GO)

Source: Internet
Author: User

public class Arraycopytest
{
public static void Main (string[] args)
{
Static initialization of two arrays of different lengths
int src[] = {1,2,3,4,5,6};
int dest[] = {10,9,8,7,6,5,4,3,2,1};

Copy the 4 elements of the array src into the array dest
System.arraycopy (src,1,dest,2,4);

Output array dest
for (int i=0;i<10;i++)
{
System.out.println (Dest[i]);
}
}
}//arraycopy (object src, int srcstartindex, object dest, int deststartindex, int length)
Copies an array from the specified source array, starting at the specified location and ending at the specified position in the destination array.
Srcstartindex: The position of the first element in the original array to begin copying
Deststartindex: The position of the first element in the destination array to begin replacing
Length: The number of elements to copy is transferred from: http://shylx123.blog.51cto.com/2081576/538540

[Java] arraycopy array copy (GO)

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.