-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathass19.java
More file actions
22 lines (22 loc) · 884 Bytes
/
Copy pathass19.java
File metadata and controls
22 lines (22 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public class ass19 {
public static void main(String[] args) {
int[] originalArray = {1, 2, 3, 4, 5};
int[] copiedArray = new int[originalArray.length];
// Copy elements
for (int i = 0; i < originalArray.length; i++) {
copiedArray[i] = originalArray[i];
}
System.out.print("Array = {");
for (int i = 0; i < originalArray.length; i++) {
System.out.print(originalArray[i]);
if (i < originalArray.length - 1) System.out.print(", ");
}
System.out.println("}");
System.out.print("Copy Array Elements one to Another Array = {");
for (int i = 0; i < copiedArray.length; i++) {
System.out.print(copiedArray[i]);
if (i < copiedArray.length - 1) System.out.print(", ");
}
System.out.println("}");
}
}