Lesson 18 of 34

Methods: വീണ്ടും ഉപയോഗിക്കാവുന്ന കോഡ്

9 min 25 XP

Method എന്നത് പേരുള്ള ഒരു കോഡ് block ആണ്: ഒരിക്കൽ എഴുതൂ, പലതവണ call ചെയ്യൂ. ഇപ്പോൾ main()-ന് അടുത്ത് static methods എഴുതാം. Parameters values അകത്തേക്ക് അയയ്ക്കുന്നു.

Example: edit me and press Run

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

void എന്നാൽ method ഒരു value-ഉം തിരികെ നൽകുന്നില്ല. അടുത്ത lesson: value തിരികെ നൽകുന്ന methods.

Challenge

+25 XP

ഇങ്ങനെ print ചെയ്യുന്ന printBox(String text) method എഴുതൂ: [ text ] main()-ൽ input-ന്റെ ഒരു വരി വായിച്ച് അതുപയോഗിച്ച് printBox call ചെയ്യൂ. Input: Hello Output: [ Hello ]

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