Yes, it prints out a bunch of "10"'s and then I have it exit.
By this point, there are no objects yet in the vector.
Well if there aren't any objects in it, you want it to be returning 0, so that's your problem right there.
for(int i = 0; i < monitorsVector.capacity(); i++)
return ((FileMonitor) monitorsVector.elementAt(i));
Change .capacity() to .size()
Capacity is how much it can hold without enlarging, size is how much it currently holds.
I find the API Specs
are very useful (choose the version of Java that you're using).
Could it be that java crashes when it tries to change a null (or garbage) to a string?
That would probably give you a null pointer exception, instead of what you're getting.
It looks like the array bounds checking is giving the error, which means the index is invalid. If Java lacked array bounds checking, it would probably give you a null pointer exception.
If an array has 0 objects, and you try to get from 0 - 9 of it, it will give you that ArrayIndexOutOfBounds exception.