Seems there are edge cases where the null pointer can happen for some words. The fix is to add a test for null: for (int i = 0; i < pointers.length; ++i) { if (pointers[i].getType() != null) { //ADDED JP if (pointers[i].getType().equals(type) ...