ich habe ein Problem mit Arrays, bekomme ständig fehler meldung Array.indes.outOfBounds...
ich habe es schon mit zwei möglichkeiten versucht, einmal das array schrittweise zu kopieren, dann mit der methode system.arraycopy, aber jedes mal bekomme ich den fehler, ich sehe ihn nicht! :bahnhof:
kann mal jemand drüber schauen...?
schon mal danke im vorraus!
ich habe es schon mit zwei möglichkeiten versucht, einmal das array schrittweise zu kopieren, dann mit der methode system.arraycopy, aber jedes mal bekomme ich den fehler, ich sehe ihn nicht! :bahnhof:
kann mal jemand drüber schauen...?
schon mal danke im vorraus!
Code:
// EIn Feld von Zellen
private static int[][] feld = new int[kante][kante];
public void feldInit()
{
int count = (kante*kante)-1;
int[] hilf = new int[kante*kante];
for(int i=0; i<kante; i++)
for(int j=0; j<kante; j++)
{
hilf[count] = 1+i;
count--;
}
for(int i=0; i<hilf.length; i++)
{
int j = (int)(hilf.length*Math.random());
int dummy = hilf[i];
hilf[i] = hilf[j];
hilf[j] = dummy;
}
// variante 1
System.arraycopy(hilf, 0, feld, 0, hilf.length);
// variante 2
int zaehler = (kante*kante)-1;
for(int i=0; i<kante; i++)
for(int j=0; j<kante; j++)
{
feld[i][j] = hilf[zaehler];
zaehler--;
}
}