dev only

Methods, Signatures & Parameters

What a Method Is

A method is a named block of code that runs when you call it. System.out.println(...) is a method call — you've been calling methods since Lesson 1.2 without needing to know how println is implemented internally. That's the whole benefit: you use a method by its name and what it does, not by reading its insides.

Signature, Parameters, Arguments

A method's signature is its name plus its parameter types — what you need to know to call it correctly.

public void rampTo(double targetSpeed) { ... }

targetSpeed here is a parameter — a variable declared in the method's header, usable inside the method's body. When you actually call the method:

drivetrain.rampTo(0.8);

0.8 is the argument — the real value being passed in. "Parameter" and "argument" describe the same slot from two different sides: the parameter is the variable in the method; the argument is the value at the call site.

Call by Value

Java copies the argument's value into the parameter — call by value. If the method changes its own parameter internally, the original value the caller passed in is unaffected; only a copy went in.

Overloading

Two methods can share the same name if their parameter lists differ in number or type — this is overloading. System.out.println() is a real example: there's a version for no arguments, one for a String, one for an int, and more — Java picks the right one based on what you pass in.

void println()          // no parameters
void println(String x)  // takes a String
void println(int x)     // takes an int

Common Pitfalls

  • Mixing up "parameter" and "argument." They're often used loosely as if interchangeable, but precisely: parameter = the variable in the method header, argument = the value at the call site.
  • Assuming a method can change the caller's original value. Call by value means the method only ever gets a copy — reassigning a parameter inside the method never affects the variable the caller passed in.
  • Wrong argument count or type. The compiler checks a call's arguments against the method's signature — mismatches (wrong count, wrong type, wrong order) won't compile.

Key Takeaways

  • A method's signature is its name plus its parameter types.
  • A parameter is a variable in the method's own header; an argument is the actual value passed in at the call site.
  • Java uses call by value — a method receives a copy of each argument, not the original.
  • Overloading means multiple methods share a name but differ in their parameter lists; Java picks the matching one based on the call.

Derived from csawesome-2026: unit-1-using-objects-and-methods/1.09-method-signatures.md (CSA 1.9)