return types

Return Types

 in OCJP
static int m(intx){
SOP("b4);
int a=x+10;
stop("after");
return a;
}
PSVM(){
int y=12;
SOP(m(y));
}

*Method එක තුලට values ඇතුල් කිරීම parametre list එක හරහා සිදු කෙරේ.

*method එකට values මෙවීම method එකට  call කරන අවස්තාවේදී එහි  brackets තුලින් values එවීම මගින් සිදු කල හැක.
* එම එවන ලද values අල්ලා ගැනීමට parametre list  එක තුල ගැලපෙන parametres සිටිය යුතුය.

*(int value එකක් අල්ලා ගැනීමට නම් int parametre එකක් හෝ ඊට වැඩි data type එකක් තිබිය යුතුය.

*method එක තුල යම් process එකක් සිදුවේ.

*Return type එක හරහා method එකින් values return කිරීම සිදුවෙයි.

*method එක තුලින් value එකක් return කිරීමට return statement එක භාවිතා කරයි.

*return type එක void නම් values return කල නොහැක.

*return type එක සඳහා ඕනෑම data type එකක් භාවිතා කල හැක.

*return statement එක තිබිය යුත්තේ method එකේ අන්තිම line එක ලෙසය.

int name method එකේ parametres වල string value එකක් ඉල්ලා ඇත.
එම නිසා method එකට call කරන  ඕනෑම අවස්තාවක දී string value එකක් pass කල යුතුය.
මෙහිදී java  යන ස්ට්‍රින්ග් value එක method එකට call කරන විට JVM එක හරහා pass කර ඇත.

*method එක තුලදී s නැමැති string variable එකට java string එක assing වී string variableක් සෑදේ. |method එක තුල එය print කර ඇත

0 comments:

Post a Comment