Lesson 19 of 34
Return ValuesReturn Values
9 min 30 XP
Method ஒரு மதிப்பைத் திருப்பித் தர வேண்டுமெனில் void-க்கு பதிலாக அந்த type-ஐ (int, double, boolean, String) எழுதி return பயன்படுத்துங்கள். return இயங்கியவுடன் method முடிந்துவிடும்.
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
Press Run to see the result here.நல்ல method ஒரே ஒரு வேலையைச் செய்யும், அதன் பெயர் அந்த வேலையைச் சொல்லும்: isPrime, findMax, calculateTax.
A good method does one job and its name says what: isPrime, findMax, calculateTax.