I think it's because you're populating the array from 1 instead of 0. Then your Math.floor random call at the bottom is occasionally looking for an object at 0.
I'm assuming that class is compiled so nothing to load.