Polymorphism and method overloading

前端 未结 5 754
深忆病人
深忆病人 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:22

    another related question for you to think about:

    public static void main(String[] args)
    {
       A a = new A();
       Object n = new Integer(1);
       a.m(n); // which method will be called?
    }
    

提交回复
热议问题