我个人理解,接口本质上是抽象类,依此理解的话,HashMap就是Map的子类对不对?
所以以上语句会出现运行期绑定?还是我哪里理解错了?
java子类可以重载父类的方法,而不overload那个方法?
黄舟2017-04-18 10:56:11
In Java, the constructor of Map map = new HashMap()
是在编译期就通过类型推断绑定了, 可以看到这里已经显式的调用了 HashMap
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...
黄舟2017-04-18 10:56:11
The nature of Java is to perform type inference at compile time, not at runtime.