Java is asking for a return statement, but I'm returning "something"
<p>So I have a simple method that takes two inputs a String and an array list of strings. I try to search for the given string in the given array list and if it's found I return it, if not I return a statement saying that it wasn't found
here's my code:</p>

<pre><code>String findWord(String word, ArrayList&lt;String&gt; list){
    for(int i=0; i&lt;list.size(); i++)
        if(word.equals(list.get(i)))
            return word;
        else
            return "Word not found";
}
</code></pre>

<p>I also tried:</p>

<pre><code>String findWord(String word, ArrayList&lt;String&gt; list){
    String myString = null;
    for(int i=0; i&lt;list.size(); i++)
        if(word.equals(list.get(i)))
            myString= word;
        else
            myString = "Word not found";
    return myString;
}
</code></pre>

<p>but the return value is always null.</p>
