Please enable JavaScript to use CodeHS

CodeHS Glossary


Calling a method Java

Calling a method actually gives the command, so the computer will run the code for that method.

As opposed to defining a method, calling a method actually runs code. In order to call a method, you must define it first, so the computer knows what to do.

Example in Karel

private void start() {
    move();
    turnRight(); // Calls the method
}

// Defines the method
private void turnRight() {
    turnLeft();
    turnLeft();
    turnLeft();
}

When you just define a method, it does not run any of the commands inside it. You need to actually call the method where you want the commands to actually run.