Professional Documents
Culture Documents
Copy Arra
Copy Arra
int length) Copies an array from the specified source array, beginning at the specif ied position, to the specified position of the destination array. The arraycopy( ) method can be used to copy quickly an array of any type from on e place to another. public class Main { static byte a[] = {65, 66, 67, 68, 69, 70, 71, 72, 73, 74}; static byte b[] = {77, 77, 77, 77, 77, 77, 77, 77, 77, 77}; public static void main(String args[]) { System.out.println("a = " + new String(a)); System.out.println("b = " + new String(b)); System.arraycopy(a, 0, b, 0, a.length); System.out.println("a = " + new String(a)); System.out.println("b = " + new String(b)); System.arraycopy(a, 0, a, 1, a.length - 1); System.arraycopy(b, 1, b, 0, b.length - 1); System.out.println("a = " + new String(a)); System.out.println("b = " + new String(b)); } }