Polymorphism and method overloading

前端 未结 5 739
深忆病人
深忆病人 2020-12-25 11:52

I have a quick and straighforward question:

I have this simple class:

public class A
{
    public void m(Object o)
    {
      System.out.println(\"m         


        
5条回答
  •  隐瞒了意图╮
    2020-12-25 12:34

    1. This is not polymorphism or overriding. This is method overloading.
    2. I tested this and specific method is being called (not the m(Object)) and according to the spec the specific method is always called. Which overload will get selected for null in Java?

提交回复
热议问题