Lesson 19 of 34

Return Values

9 min 30 XP

Value తిరిగి ఇవ్వడానికి void బదులు దాని type (int, double, boolean, String) రాసి return వాడండి. return నడిచిన వెంటనే method ముగుస్తుంది.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

మంచి method ఒకే పని చేస్తుంది, దాని పేరు ఆ పనిని చెబుతుంది: isPrime, findMax, calculateTax.

Challenge

+30 XP

static long factorial(int n) method రాయండి. main() లో n చదివి factorial(n) print చేయండి. Input: 5 → Output: 120

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.