+ 1
Let's assume you want to move a bunch of integers from user input to an array of int. The following code will do the trick: Scanner sc = new Scanner(System.in); System.out.println("How many integers do you want to give?"); int numberOfNumbers = sc.nextInt(); // Let the user say how many numbers are coming. int numbers[] = new int[numberOfNumbers]; for (int i = 0; i < numbers.length; i++) { numbers[i] = sc.nextInt(); }
13th Oct 2020, 6:17 AM
Josh Greig
Josh Greig - avatar