-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresizingarray.java
More file actions
38 lines (32 loc) · 835 Bytes
/
resizingarray.java
File metadata and controls
38 lines (32 loc) · 835 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
38
import java.util.Scanner;
public class resizingarray {
public static void main(String arg[])
{
int array[]={1,2,3,4,5};
int length = array.length;
for(int i=0 ; i<array.length ; i++)
{
System.out.print(array[i]+" ");
}
array = resizearray(array);
Scanner s=new Scanner(System.in);
for(int i =length ; i<array.length ; i++)
{
System.out.print("array["+i+"] ");
array[i]=s.nextInt();
}
for(int i =0 ; i<array.length ; i++)
{
System.out.print(array[i]+" ");
}
}
public static int[] resizearray(int[] arr)
{
int newarr[]=new int[10];
for(int i=0 ; i<arr.length ; i++)
{
newarr[i]=arr[i];
}
return newarr;
}
}