Course contentsShow
← Java
Lesson 206 of 2,8705. Methods and Function CallsFree lesson

What Is a Method Signature?

Define method signature as name plus parameter list; return type is not part of the signature.

What Is a Method Signature?

In this lesson, you'll learn how Java uniquely identifies methods using their signature—the combination of name and parameters.

The Core Idea

When you define a method in Java, the compiler needs a way to tell methods apart. The method signature is the unique identifier Java uses for this purpose. It consists of exactly two parts:

  1. The method name
  2. The parameter list (the number, types, and order of parameters)

Here's the critical point: the return type is NOT part of the signature. This surprises many beginners, but it's fundamental to how Java distinguishes one method from another.

Why This Matters

Think of a method signature like a person's full name and fingerprint combined. Two people might have the same first name (like two methods both called calculate), but if their fingerprints differ (different parameters), they're clearly different people.

// These have DIFFERENT signatures (different parameter lists)
public int add(int a, int b)
public int add(int a, int b, int c)
public int add(double a, double b)

// These have the SAME signature (same name and parameters)
public int multiply(int x, int y)
public double multiply(int x, int y)  // ERROR! Can't distinguish

In the last example, even though the return types differ (int vs double), Java cannot tell these methods apart because their signatures are identical—both are multiply(int, int).

This rule becomes crucial when you start overloading methods (defining multiple methods with the same name but different parameters), which Java permits as long as each has a unique signature.

Key Takeaway: A method signature = method name + parameter list. The return type doesn't count, so two methods can't differ only by return type.