Hallo!
Ich hab ein Problem, welches ich nicht selbst beheben kann. Hoffe mir kann einer helfen. Der Compiler schmeisst ne Nullpointer Exception und ich hab keinen blassen Schimmer wieso... mit den dingern hab ich eh nur Aerger bisher...
Ich pack mal die Klassen und der Compilerfehler mit rein.
Vieln Dank schonmal!
Ich hab ein Problem, welches ich nicht selbst beheben kann. Hoffe mir kann einer helfen. Der Compiler schmeisst ne Nullpointer Exception und ich hab keinen blassen Schimmer wieso... mit den dingern hab ich eh nur Aerger bisher...
Ich pack mal die Klassen und der Compilerfehler mit rein.
Vieln Dank schonmal!
Code:
package game;
public class Cell
{
private int value = 0;
private boolean visited = false;
public Cell()
{
value = 0;
visited = false;
}
public int getValue()
{
return(value);
}
}
--------------------------------------------------------
package game;
public class Feld
{
private Cell[][] meinFeld;
private Cell theCell = null;
public Feld()
{
theCell = new Cell();
for( int i=0; i<=20; i++)
{
for( int j=0; j<=20; j++)
{
meinFeld[i][j] = theCell;
}
}
}
public Cell[][] getFeld()
{
return(meinFeld);
}
}
--------------------------------------------------------
package game;
public class Test
{
public static void main( String [] args)
{
Feld theFeld = new Feld();
System.out.println(theFeld.getFeld()[1][1].getValue());
}
}
----------------------------------------
java.lang.NullPointerException
at game.Feld.<init>(Feld.java:15)
at game.Test.main(Test.java:9)
Exception in thread "main"
Process game.Test exited abnormally with code 1