Java Basics Hardening The Arraycopy () method of the 86:system class (array copy)

Source: Internet
Author: User
Tags time in milliseconds

1. Arraycopy method (array copy)

1  Public  Static void arraycopy (object src,int srcpos,object dest,intint length)

Copies an array from the specified array, starting at the specified position and ending at the specified position in the destination array.

Parameters:

SRC-source Array

Srcpos-Starting position in the source array

Dest-Destination Array

Destpos-start position in the target data

Length-The number of array elements to copy

2. code example:

1  Packagecn.itcast_03;2 3 Importjava.util.Arrays;4 5 /*6 * The System class contains some useful class fields and methods. It cannot be instantiated. 7  * 8 * Method:9 * public static void GC (): Runs the garbage collector. Ten * public static void exit (int status): Terminates the currently running Java virtual machine. The parameter is used as a status code; By convention, a status code other than 0 indicates an abnormal termination.  One * public static Long Currenttimemillis (): Returns the current time in milliseconds A * public static void Arraycopy (Object src,int srcpos,object dest,int destpos,int length) - * Copies an array from the specified source array, starting at the specified position and ending at the specified position in the destination array.  -  */ the  Public classSystemdemo { -      Public Static voidMain (string[] args) { -         //Defining Arrays -         int[] arr = {11, 22, 33, 44, 55 }; +         int[] arr2 = {6, 7, 8, 9, 10 }; -  +         //please look at the meaning of this code ASystem.arraycopy (arr, 1, ARR2, 2, 2); at  - System.out.println (arrays.tostring (arr)); - System.out.println (arrays.tostring (ARR2)); -     } -}

The results are as follows:

Java Basics Hardening The Arraycopy () method of the 86:system class (array copy)

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.