我個(gè)人理解,接口本質(zhì)上是抽象類(lèi),依此理解的話,HashMap就是Map的子類(lèi)對(duì)不對(duì)?
所以以上語(yǔ)句會(huì)出現(xiàn)運(yùn)行期綁定?還是我哪里理解錯(cuò)了?
java子類(lèi)可以重載父類(lèi)的方法,而不overload那個(gè)方法?
In Java, the constructor of Map map = new HashMap()
是在編譯期就通過(guò)類(lèi)型推斷綁定了, 可以看到這里已經(jīng)顯式的調(diào)用了 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...
The nature of Java is to perform type inference at compile time, not at runtime.