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.