I have a question regarding return statements used within if() while() or for() statements. As you can see in the following method, it
if()
while()
for()
Try with, as if if condition returns false, so it will return empty otherwise nothing to return.
if condition
public String myMethod() { if(condition) { return x; } return "" }
Because the compiler doesn't know if any of those if blocks will ever be reached, so it's giving you an error.