I have a method that returns all the names of people in a LinkedList for a plane.
However even though there is a return statement in the method, I'm still getting told there is a missing return statement.
How can I work around this without putting another return statement in? Why isn't it considered valid? Does putting another return statement in change what is returned?
Any feedback is greatly appreciated.
public String check() {
for (Person person: passengers)
{
return person.getName();
}
}
returnsomethingy, i.e. if there is nopassengerin passengers, even then the block mustreturn` some value. Do the needful, such that the method is able to take care of this scenario as well :-)