I will answer the question "How to fill an array of elements entered from the keyboard." For this we need a Scanner .
public static void main(String[] args) { Scanner input = new Scanner(System.in); // ΠΠ±ΡΡΠ²Π»ΡΠ΅ΠΌ Scanner System.out.println("Enter array length: "); int size = input.nextInt(); // Π§ΠΈΡΠ°Π΅ΠΌ Ρ ΠΊΠ»Π°Π²ΠΈΠ°ΡΡΡΡ ΡΠ°Π·ΠΌΠ΅Ρ ΠΌΠ°ΡΡΠΈΠ²Π° ΠΈ Π·Π°ΠΏΠΈΡΡΠ²Π°Π΅ΠΌ Π² size int array[] = new int[size]; // Π‘ΠΎΠ·Π΄Π°ΡΠΌ ΠΌΠ°ΡΡΠΈΠ² int ΡΠ°Π·ΠΌΠ΅ΡΠΎΠΌ Π² size System.out.println("Insert array elements:"); /*ΠΡΠΎΠΉΠ΄ΡΠΌΡΡ ΠΏΠΎ Π²ΡΠ΅ΠΌΡ ΠΌΠ°ΡΡΠΈΠ²Ρ, Π·Π°ΠΏΠΎΠ»Π½ΡΡ Π΅Π³ΠΎ*/ for (int i = 0; i < size; i++) { array[i] = input.nextInt(); // ΠΠ°ΠΏΠΎΠ»Π½ΡΠ΅ΠΌ ΠΌΠ°ΡΡΠΈΠ² ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ°ΠΌΠΈ, Π²Π²Π΅Π΄ΡΠ½Π½ΡΠΌΠΈ Ρ ΠΊΠ»Π°Π²ΠΈΠ°ΡΡΡΡ } System.out.print ("Inserted array elements:"); for (int i = 0; i < size; i++) { System.out.print (" " + array[i]); // ΠΡΠ²ΠΎΠ΄ΠΈΠΌ Π½Π° ΡΠΊΡΠ°Π½, ΠΏΠΎΠ»ΡΡΠ΅Π½Π½ΡΠΉ ΠΌΠ°ΡΡΠΈΠ² } System.out.println(); }
And then work with the array in the same way as you used to work with an array filled with random numbers.
Scannerin Java. With it, you will enter the elements from the keyboard. - LEQADA pm