-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDayNineteen.java
34 lines (26 loc) · 1003 Bytes
/
DayNineteen.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
public class DayNineteen {
// Function that copy one array into another array.
static void copyArrayElements(int firstArray[], int secondArray[]) {
for (int i = 0; i < firstArray.length; i++) {
secondArray[i] = firstArray[i];
}
}
public static void main(String[] args) {
// Original array
int firstArray[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
// Print original array
System.out.print("Elements of original array : ");
for (int i = 0; i < firstArray.length; i++) {
System.out.print(firstArray[i] + " ");
}
// copied array
int secondArray[] = new int[firstArray.length];
// call the copyArrayElements() function
copyArrayElements(firstArray, secondArray);
System.out.println();
System.out.print("Elements of copied array : ");
for (int i = 0; i < secondArray.length; i++) {
System.out.print(secondArray[i] + " ");
}
}
}