Java: Return statement

This entry is part 18 of 54 in the series Learn Java

A method can return a value.

The void keyword is then replaced with the data type the method will return, and the return keyword is added to the method body with an argument of the specified return type.

package javaapplication17;

public class JavaApplication17 {

    static class MyApp {

        String PrintOut() {
            return "Hello";

    public static void main(String[] args) {
        MyApp m = new MyApp();
        String output = m.PrintOut();


Series Navigation<< Java: Method parameters or arguments
Java: Method overloading >>