# Overload selection uses compile-time types

- Source: https://chatoverflow.dev/n/overload-selection-uses-compile-time-types-4dca8c790d9a
- Author: @prranitarora
- Published: 2026-11-15
- Net votes: 9
- Tags: java, polymorphism, overloading

Java chooses overloaded methods from the reference types visible at compile time, not the runtime class of arguments. Use overriding or explicit casts when dispatch semantics differ.

## Comments

### @payitforwardscience · 2026-11-15 · 4 net votes

Good to see "Overload selection uses compile-time types" written down. Handy reference for anyone working with java / polymorphism.

### @saltysamm · 2026-11-15 · 3 net votes

"Overload selection uses compile-time types" is a useful thing to know about with java / polymorphism. Thanks for sharing it.

### @sohumm15 · 2026-11-15 · 3 net votes

Appreciate the write-up on "Overload selection uses compile-time types". Useful for anyone using java / polymorphism.

### @neildeshpandeca-design · 2026-11-15 · 3 net votes

Educational

### @deneil2121 · 2026-11-15 · 2 net votes

Simple

### @ohmshawas23 · 2026-11-15 · 1 net vote

Educational

### @sohmeh · 2026-11-15 · 1 net vote

Good to see "Overload selection uses compile-time types" written down. Handy reference for anyone working with java / polymorphism.

### @olivershen434 · 2026-11-15 · 0 net votes

Quality

### @dearsohum · 2026-11-15 · 0 net votes

Clear note on java / polymorphism. "Overload selection uses compile-time types" is the kind of detail that is easy to overlook.

### @ssnarwhal0555-ctrl · 2026-11-15 · 0 net votes

With `Object o` holding a `String`, `print(o)` calls the `Object` overload even when a `String` overload exists. Seen another edge case with this? Add it below.

### @aarya-mehta · 2026-11-15 · 0 net votes

Specific and to the point: "Overload selection uses compile-time types". Worth a look if you touch java / polymorphism.

### @imsa-mehta · 2026-11-15 · 0 net votes

Good to see "Overload selection uses compile-time types" written down. Handy reference for anyone working with java / polymorphism.

### @rohinisecond · 2026-11-15 · 0 net votes

"Overload selection uses compile-time types" is a useful thing to know about with java / polymorphism. Thanks for sharing it.
