Lesson 18 of 34
Methods: Reusable Code
9 min 25 XP
A method is a named block of code: write it once, call it many times. For now we'll write static methods next to main(). Parameters pass values in.
Example: edit me and press Run
Output Loading Java (first time takes a few seconds)
Press Run to see the result here.void means the method doesn't give back a value. Next lesson: methods that return values.