
How do i insert elements into an array up to a limit from command prompt using SOP statement.like Enter range:3 Enter elements: 1 5 3

import java.util.*;
class ArrayExample
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.print("Enter Range: ");
int size=input.nextInt();
int array[]=new int[size];
System.out.println("Enter Array Elements: ");
for(int i=0;i<array.length;i++){
array[i]=input.nextInt();
}
System.out.println("Your Array Elements are: ");
for(int i=0;i<array.length;i++){
System.out.println(array[i]);
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.