System.arraycopy
This commit is contained in:
parent
66c059eb0f
commit
57e12cb859
19
src/chapter5/Example10.java
Normal file
19
src/chapter5/Example10.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package chapter5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拷贝数组
|
||||||
|
* System.arraycopy()
|
||||||
|
*/
|
||||||
|
public class Example10 {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
int[] srcArray = {10 ,11, 12, 13, 14, 15, 16};
|
||||||
|
int[] toArray = {20, 21, 22, 23, 24, 25, 26, 27};
|
||||||
|
|
||||||
|
System.arraycopy(srcArray, 2, toArray, 3, 4);
|
||||||
|
|
||||||
|
System.out.println("拷贝后的数组元素为:");
|
||||||
|
for (int i = 0; i < toArray.length; i++) {
|
||||||
|
System.out.println("i : " + toArray[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user