
giving input from outside for array example

Java Input Array Elements
import java.util.*;
class ArrayExample2
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
int array[]=new int[5];
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.