Two methods with the same name in java -


i noticed if have 2 methods same name, first 1 accepts someobject , second 1 accepts object extending someobject when call method someotherobject, automatically uses 1 accepts someobject. if cast someotherobject someobject, method accepts someobject used, if object instanceof someotherobject. means method selected when compiling. why?

that's how method overload resolution in java works: method selected @ compile time.

for of ugly details, see the java language specification §15.12.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -