Hi, I'm learning java and I was making a program where you can set the numbers for an array, and then after that you can modify the index position of the array, everything works until the last point where I need to print the array again, no error occurs, it just loads forever, and the program is running, I'm using VS Code, the code for this program is below.
import java.util.Arrays;
import java.util.Scanner;
public class editarrays {
public static void main(String[] args) {
int[] array = new int[5];
for (int i = 0; i < array.length; i++) {
Scanner number = new Scanner(System.in);
System.out.println("Enter number for index " + i);
array[i] = number.nextInt();
}
//for (int count = 0; count < array.length; count++) {
// System.out.println(array[count]);
//}
System.out.println(Arrays.toString(array));
Scanner indexToModify = new Scanner(System.in);
System.out.println("Enter the index number you want to modify: ");
Scanner setInt = new Scanner(System.in);
System.out.println("Enter the new value for index position " + indexToModify.nextInt());
array[indexToModify.nextInt()] = setInt.nextInt();
System.out.println(Arrays.toString(array));
}
}


