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: values తిరిగి ఇచ్చే 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.