Skip to content

Latest commit

 

History

History
22 lines (15 loc) · 386 Bytes

File metadata and controls

22 lines (15 loc) · 386 Bytes

Declaration

The return type of a method is written to the left of the name of the method.

To have a method which returns an int, you write int methodName.

int returnsEight() {
    return 8;
}

To have a method with returns a String, you write String methodName.

String getName() {
    return "bob";
}

And so on for any type in Java.