forked from FatimaAlazazi/DataStructure2021
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClone.java
More file actions
34 lines (29 loc) · 839 Bytes
/
Clone.java
File metadata and controls
34 lines (29 loc) · 839 Bytes
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
package Task2;
public class Clone {
static int [] a = {7,2,4,5,6,3,1};
static int [] b = new int[a.length];
static public void Clone()
{
for (int i = 0; i <a.length ; i++) {
b[i]=a[i];
}
}
static public void Print_Cloned_Array()
{
System.out.print("[ ");
for (int i = 0; i <b.length ; i++) {
if(i==b.length-1)
System.out.print(b[i]+" ]");
else
System.out.print(b[i]+" , ");
}
}
public static void main(String[] args) {
System.out.println("The Array Before Clone : ");
Print_Cloned_Array();
System.out.println("\n\n");
System.out.println("The Array After Clone : ");
Clone();
Print_Cloned_Array();
}
}