---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 25 Edition"
java_version: 25
chapter: "Chapter 13. Binary Compatibility"
section: "13.4.23"
heading: "13.4.23. Method and Constructor Overloading"
parent: "13.4. Evolution of Classes"
source: https://docs.oracle.com/javase/specs/jls/se25/html/jls-13.html#jls-13.4.23
id: "13.4.23"
url: https://jvm.obfuscated.software/jls/se25/13.4.23.html
raw: https://jvm.obfuscated.software/jls/se25/13.4.23.md
---

# 13.4.23. Method and Constructor Overloading

Adding new methods or constructors that overload existing methods or constructors does not break compatibility with pre-existing binaries. The signature to be used for each invocation was determined when these existing binaries were compiled; therefore newly added methods or constructors will not be used, even if their signatures are both applicable and more specific than the signature originally chosen.

While adding a new overloaded method or constructor may cause a compile-time error the next time a class or interface is compiled because there is no method or constructor that is most specific ([§15.12.2.5](15.12.2.5.md)), no such error occurs when a program is executed, because no overload resolution is done at execution time.

**Example 13.4.23-1. Adding An Overloaded Method**

```
class Super {
    static void out(float f) {
        System.out.println("float");
    }
}
class Test {
    public static void main(String[] args) {
        Super.out(2);
    }
}
```

This program produces the output:

```
float
```

Suppose that a new version of class `Super` is produced:

```
class Super {
    static void out(float f) { System.out.println("float"); }
    static void out(int i)   { System.out.println("int");   }
}
```

If `Super` is recompiled but not `Test`, then running the new binary with the existing binary of Test still produces the output:

```
float
```

However, if `Test` is then recompiled, using this new `Super`, the output is then:

```
int
```

as might have been naively expected in the previous case.
