Compiler Error J0105

Method 'identifier' must return a value

The compiler detected a method declaration that included a return type other than void, but the keyword return was not found in the method body. This error usually occurs when a method that returns a value is missing a valid return statement. This error can also occur if a return statement is called within a flow control block and cannot always be accessed due to the logic of the method.

The following example illustrates this error:

public class Simple {
   
   public int method1(int arg1) {
      if (arg1==0)
         return arg1 + 2;
   } // error: flow control prohibits a value from always being returned
}