-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathArrayDemo.java
38 lines (29 loc) · 916 Bytes
/
ArrayDemo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.util.Arrays;
public class ArrayDemo {
static int[] arrCpy(int[] arr) {
int[] intArr2 = arr.clone();
return intArr2;
}
public static void main(String[] args) {
int[] intArr1 = { 5, 7, 51, 2, 3, 0 };
System.out.println("\nOriginal array is:");
for (int i : intArr1) {
System.out.print(i + " ");
}
int[] copiedArr = arrCpy(intArr1);
System.out.println("\nCopied array is:");
for (int i : copiedArr) {
System.out.print(i + " ");
}
intArr1[2] = 8;
System.out.println("\nAfter modification::");
System.out.println("\nOriginal array is:");
for (int i : intArr1) {
System.out.print(i + " ");
}
System.out.println("\nCopied array is:");
for (int i : copiedArr) {
System.out.print(i + " ");
}
}
}