Lessons

Java tutorial

Java Methods

A method is a named block you can call. Parameters bring values in, and return sends one value back. A static method belongs to the class, so main can call it by name.

Example

Edit the code and run it again. This runner stays in your browser and covers the syntax used in these lessons.

Output

Run the example to see output here.

What this code does

square receives 6, multiplies it by itself, and returns 36. main prints the returned value.