Overloading in Java and multiple dispatch

前端 未结 6 1382
走了就别回头了
走了就别回头了 2020-11-28 09:16

I have a collection (or list or array list) in which I want to put both String values and double values. I decided to make it a collection of objects and using overloading o

6条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 09:46

    When calling a method that is overloaded, Java picks the most restrictive type based on the type of the variable passed to the function. It does not use the type of the actual instance.

提交回复
热议问题