小编Ego*_*eev的帖子

无法为TreeMap解析方法tailMap

为什么TreeMap类型Map没有定义方法tailMapheadMap.

Map<String, String> map = new TreeMap<>();
map.tailMap();  //cannot resolve method tailMap
Run Code Online (Sandbox Code Playgroud)

使用显式转换它可以工作:

((TreeMap<String, String>) map).tailMap("a");
Run Code Online (Sandbox Code Playgroud)

随着NavigableMap一切都很好:

NavigableMap<String, String> map1 = new TreeMap<>();
map1.tailMap("a");
Run Code Online (Sandbox Code Playgroud)

如果我是对的,因为界面Map缺少相应的方法,尽管面对对象map是类的具体实现TreeMap,当然确实拥有这样的方法.

只是寻找更详细的解释.

谢谢!

java dictionary interface treemap

9
推荐指数
1
解决办法
99
查看次数

标签 统计

dictionary ×1

interface ×1

java ×1

treemap ×1