Java return KeywordJava 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
Examples of Java return KeywordExample 1Let's see a simple example to return integer value. Output: 10 Example 2Let's see an example to determine whether we can use return in void method. Output: Void methods cannot return a value Example 3Let's see an example to return string. Output: Javatpoint Example 4Let's see an example to return list of elements. Output: [Java, C++, Python]
Next TopicJava Keywords
|