Javatpoint Logo
Javatpoint Logo

Java return Keyword

Java return keyword is used to complete the execution of a method. The return followed by the appropriate value that is returned to the caller. This value depends on the method return type like int method always return an integer value.

Points to remember

  • It is used to exit from the method.
  • It is not allowed to use return keyword in void method.
  • The value passed with return keyword must match with return type of the method.

Examples of Java return Keyword

Example 1

Let's see a simple example to return integer value.



Example 2

Let's see an example to determine whether we can use return in void method.


Void methods cannot return a value

Example 3

Let's see an example to return string.


[Java, C++, Python]
Next TopicJava Keywords

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA