Computer Science, asked by chintupothini, 5 months ago

java program on array operations

Answers

Answered by praseenasasi
0

Answer:

Example:

public static void main(String[] args) { int Source[] = {5,6,7,8,9,10};

int Destination[] = new int[5]; System. arraycopy(Source, 1, Destination, 0, 5);

System. out. print(Arrays. toString(Destination)); }

Answered by Anonymous
0

{\huge{\sf{\green{\underline{\underline{InnocentYashi}}}}}}

Java – Array Operations

PREV NEXT

COPYING AN ARRAY:

1. USING ARRAYCOPY() METHOD:

The arraycopy() method belongs to the System class. It is used to copy the contents of one array to the other.

Type

public static void

Description

Method

arraycopy(Object src, int srcPos, Object dest, int destPos, int length)

Copies an array from the source array, beginning at the specified position, to the specified position of the destination array.

length – the number of array elements to be copied.

Example:

C

public class ArrayCopying {

public static void main(String[] args) {

int Source[] = {5,6,7,8,9,10};

int Destination[] = new int[5];

System.arraycopy(Source, 1, Destination, 0, 5);

System.out.print(Arrays.toString(Destination));

}

}

1

2

3

4

5

6

7

8

public class ArrayCopying {

public static void main(String[] args) {

int Source[] = {5,6,7,8,9,10};

int Destination[] = new int[5];

System.arraycopy(Source, 1, Destination, 0, 5);

System.out.print(Arrays.toString(Destination));

}

}

OUTPUT:

[6, 7, 8, 9, 10]

Similar questions