Please enable JavaScript to use CodeHS

CodeHS Glossary

Method Java

A method is a way to teach the computer a new command. A method should do one simple job, and should be written like a command, like `turnRight`, or `printHello`. Methods are named with lowerCamelCase. For example, we could teach the Karel (the computer) to turn right with a method written like: ``` private void turnRight() { turnLeft(); turnLeft(); turnLeft(); } ``` Methods allow us to: 1. Break down our code into separate reusable parts 2. Make our code easier to understand 3. Avoid writing repeated code 4. Simplify our code