GayCummer
Dark Web Explorer
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
300 XP
Introduction:
Welcome! This tutorial page will teach you about the "Return" keyword in Java.
What is a 'keyword'?
A keyword is a word which already has a set/pre-defined action within Java. For example; public is a keyword which allows other classes to access the public variable or function/method.
So, what does the "Return" do?
Return is used to send a value back from a method or function to the place where it was called. The type of value to return depends on the type of method the return keyword is encased in. Below is an example of two different methods, one returning an integer, and the other returning a string.
Examples:
Setting up the call:
Returns a string:
Output:
Hey!
Returns an integer:
Output:
4
Finished!
Book traversal links for Return Keyword
Welcome! This tutorial page will teach you about the "Return" keyword in Java.
What is a 'keyword'?
A keyword is a word which already has a set/pre-defined action within Java. For example; public is a keyword which allows other classes to access the public variable or function/method.
So, what does the "Return" do?
Return is used to send a value back from a method or function to the place where it was called. The type of value to return depends on the type of method the return keyword is encased in. Below is an example of two different methods, one returning an integer, and the other returning a string.
Examples:
Setting up the call:
- System
.out
.println
(
returnThisTutorial(
)
)
;
Returns a string:
- private
static
String
returnThisTutorial(
)
{
- return
"Hey!"
;
- }
Output:
Hey!
Returns an integer:
- private
static
int
returnThisTutorial(
)
{
- return
4
;
- }
Output:
4
Finished!
Book traversal links for Return Keyword
- ‹ Reading Text Files
- Up
- Setting Up JFrame/Program Window ›