-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray5.java
More file actions
31 lines (31 loc) · 741 Bytes
/
array5.java
File metadata and controls
31 lines (31 loc) · 741 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
//Updation of array
import java.util.Scanner;
class array5
{
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 update index");
int index=new Scanner(System.in).nextInt();
System.out.println("Enter new element");
int ele=new Scanner(System.in).nextInt();
a[index-1]=ele;
System.out.println("New array:");
for (int x : a)
{
System.out.println(x);
}
}
}