1
public class1 foo ( class1 t)
{
    if ( object == null ) return t;
    else foo(t.childObject);
}

Java keeps telling me that there is no return statement. I can understand what is wrong here, but I cannot fix it without removing the recursion, which I really need. Is there any way to bypass this error?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880

1 Answers1

7

You need a return in the else case.

public class1 foo ( class1 t)
{
    if ( object == null ) return t;
    else return foo(t.childObject);
}
Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880