Hi, little code problem
The problem I got was:public void display() { for (int i = 0; i < 25; i++) { StringBuilder line = null; for (int j = 0; j < 25; j++) { line.append(puzzleArray[i][j]); //this is line 20 } System.out.println(line.toString()); //this line seems linked to the error. } }
#
Exception in thread "main" java.lang.NullPointerException
at prog4.Puzzle.display(Puzzle.java:20)
at prog4.Prog4.main(Prog4.java:8)
meanwhile when I tried the following (not what I wanted but similar there wasn't a problem)
public void display() { for (int i = 0; i < 25; i++) { for (int j = 0; j < 25; j++) { System.out.println(puzzleArray[i][j]); } } }