Skip to main content

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.

Setting up the call:

  1. System.out.println(returnThisTutorial());

Returns a string:

  1. private static String returnThisTutorial() {
  2. return "Hey!";
  3. }



Returns an integer:

  1. private static int returnThisTutorial() {
  2. return 4;
  3. }




Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.


1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.