The idea is this: there is an array without capacity. The number of elements of the array is entered by the user. Now, you need to make sure that the value of each array is set by the user.

I guess this can be implemented using a for loop. But I do not know how to do the sequential input of the value of each element of the array.

 public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Π’Π²Π΅Π΄ΠΈΡ‚Π΅ объСм массива, ΠΊΠ°ΠΊ Ρ†Π΅Π»ΠΎΠ΅ число"); int User0 = scan.nextInt(); int [] Int = new int [User0]; System.out.print(Arrays.toString(Int)); 

    1 answer 1

    For example:

     Scanner scan = new Scanner(System.in); System.out.print("Π’Π²Π΅Π΄ΠΈΡ‚Π΅ объСм массива, ΠΊΠ°ΠΊ Ρ†Π΅Π»ΠΎΠ΅ число: "); int massiveSize = scan.nextInt(); System.out.println(); if (massiveSize > 0) { int[] massive = new int[massiveSize]; for (int itemNumber = 0; itemNumber < massiveSize; ++itemNumber) { System.out.print("Π’Π²Π΅Π΄ΠΈΡ‚Π΅ " + itemNumber + " элСмСнт массива: "); massive[itemNumber] = scan.nextInt(); System.out.println(); } }