Missing return statement error even with return statement at the end of method : <p>I have this method to search for files and store them into a list and return it. The problem is that I get an "This method must return a result of type List" even I have a return statement of type List at the end of it.</p>

<pre><code>public List&lt;String&gt; cautaFisiere(String root) {
    List&lt;String&gt; list = new ArrayList&lt;String&gt;();
    File[] file = new File(root).listFiles();
    if (file == null) {
        return ;
    }
    for (File x : file) {
        if (x.getName().toLowerCase().contains(fileName.toLowerCase())) {
            System.out.println(x.getName() + " " + x.getPath());
        }
        String path = x.getPath();
        if (x.isDirectory()) {
            cautaFisiere(path);

        }

    }
    return list;
}
</code></pre>

<p>the error is on the 5th line in my code</p>
