sarò ignorante io che non capisco l'errore... comunque c'è poco da dire, il codice è questo:
e mi ritorna un'eccezione arrayOutOfBounds... alla riga di default dello switch... che non dovrebbe essere eseguita dal momento che la lunghezza di a è uguale a 2... illuminatemicodice:public CubeMatrix(int... a){System.out.print(a.length); switch(a.length){ case 1: {this.x = a[0]; this.y = 0; this.z = 0;} case 2: {this.x = a[0]; this.y = a[1]; this.z = 0;} default: {this.x = a[0]; this.y = a[1]; this.z = a[2];} } cm = (T[][])new Object[x][y]; for(int i=0; i<cm.length; i++){ for(int j=0; j<cm[0].length; j++){ cm[i][j] = (T)new Object[z]; } } } public static void main(String[] args){ CubeMatrix<Integer> cm = new CubeMatrix<Integer>(2, 3);

Rispondi quotando
