Although you might know better, as far as the compiler can tell, it's possible for control to read the end of the method without ever seeing a return statement. For example, trivially, what if array inOrder has length 0? Then the for loop's body is never executed at all, and the method immediately tries to return -- but can't, as there's no "return" statement.
So if you added a "return -1" at the very end, you'd be good. You could then replace the "return -1" inside the loop with "break", so it'd just jump to the outside return.
Originally posted by Garrett Rowe: Don't use == to compare Strings, use the equals() method.
Thanks, Garrett, I missed that!
Joined: Apr 20, 2008
Thanks again, I really appreciate it.
I love learning new languages, but there is so much to remember! You should have seen me earlier trying to solve this problem. Before I remembered the string comparisons way of comparing strings, I had this big complicated nested nested for loop with ifs and elses comparing each letter of each word, haha.