You're on the right track! Did you notice that if you tried to compile, you got some sort of error regarding this bit: `longestNameSize[i]` ? In my IDE, I get the error "array required, but not found".
That's because you're trying to treat longestNameSize as if it's an array -- see those square brackets trying to access an element of the supposed array -- but it's not an array. We can see earlier in your program, it's declared as an int -- not an array of ints, but a single int.
What you wanted to write there was something that referenced the `names` array -- the idea is that you're using that for loop to iterate over each element in that `names` array, comparing each element's length to the longest length you've found so far. So that `longestNameSize[i] `should be changed to `names[i]`.
You also forgot to actually compare the length of the item at `names[i]`. And finally, the updating of the longest length found so far in `longestNameSize` is missing. So here's the updated program, with some comments highlighting all this.
public static String findLongestName(String[] names) {
int size = names.length;
String longestName = names[0];
int longestNameSize = longestName.length();
for (int i = 1; i < size; i++) {
// Compare the length of the next item in names against the largest length found so far.
if (names[i].length() > longestNameSize) {
// We've found a longer name, so update longestName and the longestNameSize to match what
// we just found.
longestName = names[i];
longestNameSize = longestName.length();
}
}
return longestName;
}