貌似这个问题有点白痴了,
但是我有些问题想不全,希望大家给点想法。比如Map是个接口
|
|-HashMap类实现了他。
最后呢LinkedMap同时继承和实现了上述的接口和类。为什么还要实现接口呢,不实现不是也可以麽?大家说说吧。
但是我有些问题想不全,希望大家给点想法。比如Map是个接口
|
|-HashMap类实现了他。
最后呢LinkedMap同时继承和实现了上述的接口和类。为什么还要实现接口呢,不实现不是也可以麽?大家说说吧。
This implementation differs from HashMap in that it maintains a doubly-linked list running through all of its entries. This linked list defines the iteration ordering, which is normally the order in which keys were inserted into the map (insertion-order).
如果只是继承 Map里的方法就可以不用实现
如果实现接口 Map里的方法就必须实现
Map map = new LinkedMap();
直接实现了接口Map,还有一些方法LinkedHashMap直接用自HashMap吧,或者重写其中一些方法
...
没有LindedMap。
lz说错了吧
extends HashMap类 而不implement Map接口,而直接重写那么不一样的方法不可以吗?
如果只是继承 Map里的方法就可以不用实现
如果实现接口 Map里的方法就必须实现
implements Map,就可以直接拿过来用了?从Map拿过来的那些抽象的方法?没有明白你的意思.
实现了map接口而不是查看hashmap再查看hashmap的接口(个人意见哈)
这样有利于,面向接口(抽象)编程。多了解设计模式,就知道为什么这样实现了。推荐java与模式这本书