If this line:
for (int i = 0; i < b.length; i++)
throws an NPE, there is only one possible explanation. b
is null
.
You can prove (or disprove) this by adding this statement immediately before the for
statement.
System.out.println("b is " + b);
Once you've confirmed that, you need to work backwards to figure out why the b
is null
at that point. I can't offer any insights based on the code you've shown us.