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.
public List<String> cautaFisiere(String root) {
List<String> list = new ArrayList<String>();
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;
}
the error is on the 5th line in my code