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
Post a Comment