Add values in a 3-dimensional array

-1

How do I make the user add values to an array [] [] []?

calendarioEventos = new Evento[dia][mes][hora];
    for(int i = 0; i < calendarioEventos.length; i++) {
        for(int j = 0; j < calendarioEventos[i].length; j++) {
            for(int k = 0; k < calendarioEventos[i][j].length; k++) {
                this.calendarioEventos[i][j][k] = new Evento();

I have this array of an event calendar where the user has to add an event to a time of day. How do I do this?

    
asked by anonymous 29.11.2017 / 13:16

1 answer

2
Scanner input = new Scanner(System.in);
int[][][] matriz = new int[2][2][2];
for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
        for (int k = 0; k < 2; k++) {
            System.out.println("Digite o valor para Matriz[" + i + "][" + j + "][" + k + "]");
            int val = Integer.parseInt(input.nextLine());
            matriz[i][j][k] = val;
        }
    }
}
    
29.11.2017 / 13:38