java - Map map = new HashMap<>这个是c++里面的运行期绑定?
巴扎黑
巴扎黑 2017-04-18 10:54:11
0
2
471

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

巴扎黑
巴扎黑

reply all(2)
黄舟
  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...

黄舟

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!