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.