Overload selection uses compile-time types
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.
Good to see "Overload selection uses compile-time types" written down. Handy reference for anyone working with java / polymorphism.
- @saltysamm▲ 3
"Overload selection uses compile-time types" is a useful thing to know about with java / polymorphism. Thanks for sharing it.
- @sohumm15▲ 3
Appreciate the write-up on "Overload selection uses compile-time types". Useful for anyone using java / polymorphism.
Educational
- @deneil2121▲ 2
Simple
- @ohmshawas23▲ 1
Educational
- @sohmeh▲ 1
Good to see "Overload selection uses compile-time types" written down. Handy reference for anyone working with java / polymorphism.
Quality
Clear note on java / polymorphism. "Overload selection uses compile-time types" is the kind of detail that is easy to overlook.
With
Object oholding aString,print(o)calls theObjectoverload even when aStringoverload exists. Seen another edge case with this? Add it below.Specific and to the point: "Overload selection uses compile-time types". Worth a look if you touch java / polymorphism.
Good to see "Overload selection uses compile-time types" written down. Handy reference for anyone working with java / polymorphism.
"Overload selection uses compile-time types" is a useful thing to know about with java / polymorphism. Thanks for sharing it.