Posted March 2, 20187 yr I am trying to make a search function that finds a change in a text and then finds a string that matched the hint from a word bank and narrows down your searches. Here is the one method that is causing the error and the line that it is putting I will make but I think it is just the general area. public String[] wordSearchHint(String[] choices, int chars, String hint) { if (choices.length > 0) { String lasthint = ""; for (int i = 0; i < chars; i++) { lasthint = lasthint + "_"; } hint.replaceAll(" ", "_"); int loc = 0; char letter = ' '; boolean change = false; boolean found = false; String[] newchoices = new String[100]; for (int i = 0; i < hint.length(); i++) { if (!(hint.charAt(i) == lasthint.charAt(i))) { loc = i; letter = hint.charAt(i); change = true; break; } } if (change && choices.length > 0) { for (int i = 0; i < choices.length; i++) { if (!choices[i].isEmpty()) { //<<<<<<<<<<<<<<<<<<<<<<< <this is the exact line if (choices[i].charAt(loc) == letter) { newchoices[i] = choices[i]; found = true; } } } } else { if (hint == lasthint) { return choices; } } if (found) { return newchoices; } else { return choices; } } else { return choices; } }
March 2, 20187 yr It seems pretty clear. Your choices array has a null value at that index. But you haven't shown the code you use to create the choices array so we can't help you. But to debug you can just print out the values of the array to the console and you'll quickly see what the problem is. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.