-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray6.java
More file actions
33 lines (33 loc) · 740 Bytes
/
array6.java
File metadata and controls
33 lines (33 loc) · 740 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
//Deletion of aray elements
import java.util.Scanner;
class array6
{
public static void main(String[] args)
{
System.out.println("Enter the size of the array");
int size=new Scanner(System.in).nextInt();
int a[]=new int [size];
System.out.println("Enter array elements");
for(int i=0;i<size;i++)
{
a[i]=new Scanner(System.in).nextInt();
}
System.out.println("Array elements are");
for (int x : a)
{
System.out.println(x);
}
System.out.println("Enter delete index");
int index=new Scanner(System.in).nextInt();
for(int i=index;i<size;i++)
{
a[i-1]=a[i];
a[i]=0;
}
System.out.println("New array:");
for (int x : a)
{
System.out.println(x);
}
}
}