i didn't really look at the code, but here's some things to think about...
if you go forward through an array like this:
then you can go backwards through an array like this:
in other words, start at the other end and count down.
now, a null pointer error means that you have a reference to an object, but never CREATED an object. the error message should tell you at the least what line the error happened, which should help you figure out what reference is causing the problem.
In other words, somewhere in your code you have a line like
Foo myObject;
then you try and use a method in myObject, with the dot operator:
myObject.printMe();
note that you may even have something in your code that you THINK will assign an object to this reference, but it might fail and return a null...
myObject = helperObject.getNextWord();
if there is no next
word, this method returns a null, so now myObject refers to a null... you see the problem? You need to look at where you're being told the nullPointer exception is.
as to the array out of bounds, again, look at the line where you are being told this happens. how big IS the array? maybe you could print out the real size and what your index is at each step. remember that arrays are 0 indexed, so if the size is 10, you want to run from i = 0 to i < 10