search

Home  >  Q&A  >  body text

java - Map map = new HashMap<>这个是c++里面的运行期绑定?

我个人理解,接口本质上是抽象类,依此理解的话,HashMap就是Map的子类对不对?
所以以上语句会出现运行期绑定?还是我哪里理解错了?
java子类可以重载父类的方法,而不overload那个方法?

巴扎黑巴扎黑2804 days ago509

reply all(2)I'll reply

  • 黄舟

    黄舟2017-04-18 10:56:11

    1. In Java, the constructor of Map map = new HashMap() 是在编译期就通过类型推断绑定了, 可以看到这里已经显式的调用了 HashMap

    2. Overload is Overload, and "subclasses can override methods of parent classes" refers to Override, which is called rewriting or overwriting https://en.wikipedia.org/wiki...

    reply
    0
  • 黄舟

    黄舟2017-04-18 10:56:11

    The nature of Java is to perform type inference at compile time, not at runtime.

    reply
    0
  • Cancelreply