# return Java Keyword

The return keyword causes a method to return to the method that called it, passing a value that matches the return type of the returning method.

## Examples

      public void myVoidMethod()
      {
         <statements>
         return;
      }

      public String myStringMethod()
      {
         String s = "my response";
         return s;
      }

      public int myIntMethod()
      {
         int i = 5;
         return(i);
      }

## Remarks

- If the method has a non-void return type, the return statement must have an argument of the same or a compatible type.

- The parentheses surrounding the return value are optional.

Related Topics

None.