Here you can find the source of arraycopy(char[] A1, int offset1, char[] A2, int offset2, int length)
A1
starting at offset offset1
into A2
starting at offset offset2
for length
elements.
Parameter | Description |
---|---|
A1 | the array to copy out of |
offset1 | the starting index in array1 |
A2 | the array to copy into |
offset2 | the starting index in array2 |
length | the number of elements in the array to copy |
static void arraycopy(char[] A1, int offset1, char[] A2, int offset2, int length)
//package com.java2s; //License from project: Open Source License public class Main { /**/* w w w.j a va2s . c om*/ * Copies the contents of <code>A1</code> starting at offset * <code>offset1</code> into <code>A2</code> starting at offset * <code>offset2</code> for <code>length</code> elements. * * @param A1 the array to copy out of * @param offset1 the starting index in array1 * @param A2 the array to copy into * @param offset2 the starting index in array2 * @param length the number of elements in the array to copy */ static void arraycopy(char[] A1, int offset1, char[] A2, int offset2, int length) { if (offset1 >= 0 && offset2 >= 0 && length >= 0 && length <= A1.length - offset1 && length <= A2.length - offset2) { // Check if this is a forward or backwards arraycopy if (A1 != A2 || offset1 > offset2 || offset1 + length <= offset2) { for (int i = 0; i < length; ++i) { A2[offset2 + i] = A1[offset1 + i]; } } else { for (int i = length - 1; i >= 0; --i) { A2[offset2 + i] = A1[offset1 + i]; } } } else { throw new ArrayIndexOutOfBoundsException(); } } /** * Copies the contents of <code>A1</code> into <code>A2</code> for <code>length</code> elements. * * @param A1 the array to copy out of * @param A2 the array to copy into * @param length the number of elements in the array to copy */ static void arraycopy(char[] A1, char[] A2, int length) { if (length >= 0 && length <= A1.length && length <= A2.length) { for (int i = 0; i < length; ++i) { A2[i] = A1[i]; } } else { throw new ArrayIndexOutOfBoundsException(); } } }