Why is this code generating a NullPointerException?

For (int i=0; iThe first line should be inputMatrix. Length-1 Also the.

InputMatrix0. Length is alright, I took out the -1 and worked. Thanks.

– omgzor May 1 at 20:46 1 I'm not so sure inputMatrix0. Length is right in the first line. You are using "i" to index inputMatrix (i.e.

Your code has inputMatrixi), so you should compare I against the length of inputMatrix. – madri Choudhury May 1 at 21:06 in this particular case is right, as both matrices have the same length. – omgzor May 1 at 21:12 @omgzor, DasBoot is right.

You're just lucky that in your case the two lengths are the same because both dimensions of the matrix are the same size. – Adam May 1 at 21:14.

One reason it's helpful to provide line numbers of errors that the system provides to you is that it makes you look at them as well. You'd notice that your error is from this line System.out. Println("helper array 1: i,j " + helperArray1.

I + ", " + helperArray1. J); It happens because helperArray is an array of pointers (of length 2). It initially is all null.It's supposed to get initialized somewhere in that nested loop.

So I put in a print statement to see which elements get initialized and see Setting point 0 Exception in thread "main" java.lang. NullPointerException at Main. RobotInitialPositions(Main.

Java:66) at Main. Bfs_find_solution(Main. Java:83) at Main.

Main(Main. Java:130) that only point 0 gets set. But you're trying to print point 1, which is still null.

So that's why you're getting your error, I'm not sure what your code is supposed to do so I'll let you figure out what SHOULD happen.

1 give a man a fish he's full for a day, teach a man to fish, he eats for a lifetime. – MeBigFatGuy May 1 at 20:47.

I have attached my code. Any help would be appreciated. I am using Netbeans IDE 6.9.1.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions