-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCopingArray.java
More file actions
37 lines (33 loc) · 869 Bytes
/
CopingArray.java
File metadata and controls
37 lines (33 loc) · 869 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
35
36
37
//Program that copies contents of one array to another using length member.
import java.util.Scanner;
public class CopingArray
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter the size of Array :- ");
int size = sc.nextInt();
int[] array = new int[size];
System.out.print("\nEnter the Array - ");
for(int i=0; i<size; i++)
{
System.out.print("\nEnter the " +(i+1)+" element - ");
array[i]=sc.nextInt();
}
System.out.print("\nEnterd Array is -- ");
for(int i=0; i<size; i++)
{
System.out.print("\t"+array[i]);
}
int[] arr = new int[array.length];
for(int i=0; i<array.length; i++)
{
arr[i] = array[i];
}
System.out.print("\nThe copied array is :- ");
for(int i=0; i<size; i++)
{
System.out.print("\t"+arr[i]);
}
}
}