Lesson 19 of 34
Return Values
9 min 30 XP
To give a value back, replace void with its type (int, double, boolean, String) and use return. The method ends as soon as return runs.
Example: edit me and press Run
Output Loading Java (first time takes a few seconds)
Press Run to see the result here.A good method does one job and its name says what: isPrime, findMax, calculateTax.