Should methods with return type void use a return statement?

Pops picture Pops · Dec 15, 2009 · Viewed 11.9k times · Source

I know that there are times when using return; can serve a useful purpose in Java, such as in guarding:

public void foo(Bar bar) {
    if(bar == null)
        return;

    // bar is not null, go ahead and do stuff with it
}

But what about just reaching the end of a method with return type void? For example,

public void printMenu() {
    System.out.println("Print out some boilerplate info here, line 1.");
    System.out.println("Print out some boilerplate info here, line 2.");
    System.out.println("Print out some boilerplate info here, line 3.");

    return;
}

Other than pure style preferences, are there any reasons for or against including that return;? If so, what are they?

EDIT: Well, that got answered quickly. To summarize the 15 answers posted below: "No."

Answer

ChssPly76 picture ChssPly76 · Dec 15, 2009

Perhaps you're paid by line of code?

Other then that there's really no reason to put an empty return in the end.