so i’ve already made a class method that searches for a specific word, but (like most times i find myself on here!) i’ve had a brain malfunction and can’t figure out how to modify it to do what i need. here’s what i’ve got so far:
private static int findFourLetterWord(String[] strings, String key) {
for (int i = 0; i < strings.length; i++)
if (strings[i].equals(key))
return i;
return -1;
}
so this searches an array for ‘key’ and returns with it’s position if it is found. what i’m trying to get it to do is search an array of strings for the first 4 letter word it encounters and return with that word. i would change the first return to be System.out.println(strings[i]); i believe, but i’m not sure how to make it search for the first 4 letter word it finds. tried using a bunch of convoluted substrings but that didn’t work. any advice or guidance would be great. thank you in advance.
Am I understanding your question right?