Jacqueline Turof wrote:Any one have any ideas why I'm getting the error NullPointerException?
Any help is appreciated!!!
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:a line like this:
String [][] board= new String [3][3];
creates an array, but it has nothing in it.
Also..remember that java doesn't have multi-dimensional arrays. it has arrays that hold objects - and those objects can be arrays.
So, after this line, you have an array that can hold three things (which have to be arrays of String), but those things don't exist yet. So you can't call a method on them.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:
Do you actually get to the "board [i][j]= "-"; " line? I would think (and this is a guess) that you get the NPE on line 4 here. you are trying to get the length of an array that doesn't exist.>
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |