Hi I am a beginner and today I started learning about arrays. I wrote the following working program.
import java.util.Scanner;
public class Arr {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("enter some numbers");
int[] x = new int[5];
x[0] = scanner.nextInt();
x[1] = scanner.nextInt();
x[2] = scanner.nextInt();
x[3] = scanner.nextInt();
x[4] = scanner.nextInt();
String string = "the numbers as requested are : ";
for(int i = 0; i < x.length; i++) {
System.out.println(string + x[i]);
}
scanner.close();
}
}
however if my array had 1000 numbers, this process would have become tiresome. Is there an easy way to input numbers without typing input scanner for each package