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

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

java - SmsManager sending message more than one -