No livro da Kathy Sierra está escrito a seguinte afirmação:
“If you assign an array to a previously declared array reference, the array you’re assigning must be the same dimension as the reference you’re assigning it to.”
Porém, o seguinte código não fura essa afirmação?
[code]public class Teste
{
public static void main(String[] args) {
int a[][] = new int[3][4];
int b[][] = new int[4][6];
for(int x[] : a){
for(int y: x){
System.out.print(" "+y);
}
}
System.out.println();
a = b;//Aqui funciona normalmente... não era para dar erro de acordo com a afirmação acima?
for(int x[] : a){
for(int y: x){
System.out.print(" "+y);
}
}
}
}
[/code]
Obrigado!