Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 485 Bytes

return_values.md

File metadata and controls

26 lines (20 loc) · 485 Bytes

Return Values

You can use a method call on the right hand side of an = to get the value returned by the method.

int returnsEight() {
    return 8;
}

void main() {
    int value = returnsEight();
    System.out.println(value);
}

The method call can also be used directly in expressions without assigning the value to a variable first.

String returnsName() {
    return "Mariah";
}

void main() {
    System.out.println(returnsName() + " is my name");
}