泛型相关的问题

jinjiajie 2007-10-11 02:44:01
Map<String, RuntimeMonitor.ProcessCHeapInfo> gap = rt.getCHeap();
Iterator it = gap.entrySet().iterator();


就这么段代码,为什么第2行那里仍旧会提示 Iterator is a raw type.References to generic type Iterator<E>should be parameterized

...至今对泛形一头雾水,请各位大大指点一二
...全文
590 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
jinjiajie 2007-10-12
  • 打赏
  • 举报
回复
确定是eclipse 3.30的问题了....谢谢各位帮忙
lihaifeng0412 2007-10-12
  • 打赏
  • 举报
回复
顶下
jinjiajie 2007-10-12
  • 打赏
  • 举报
回复
可能是我的eclipce版本问题,5楼的写法我昨天就写了,但是ide还是提示有warning...虽然不影响机能,但是这次的改造就是要把warning全去了,头大ing。。。。
allenblade 2007-10-12
  • 打赏
  • 举报
回复
看错了....5楼
allenblade 2007-10-12
  • 打赏
  • 举报
回复
4楼的正解
shadao 2007-10-12
  • 打赏
  • 举报
回复
不好意思,弄错了 以为是values;原来你要pair

Map <String, RuntimeMonitor.ProcessCHeapInfo> gap = rt.getCHeap();
Set<Map.Entry<String, RuntimeMonitor.ProcessCHeapInfo>> sett = gap.entrySet();
for(Map.Entry<String, RuntimeMonitor.ProcessCHeapInfo> pair:sett){
pair.getKey();//the key;String
pair.getValue();//the value;RuntimeMonitor.ProcessCHeapInfo
}
jinjiajie 2007-10-12
  • 打赏
  • 举报
回复
还是不行,头大了...
neptune0229 2007-10-12
  • 打赏
  • 举报
回复
Iterator <Entry <String,RuntimeMonitor.ProcessCHeapInfo > > = gap.entrySet().iterator();
reene2008 2007-10-12
  • 打赏
  • 举报
回复
Iterator <Map.Entry <String,RuntimeMonitor.ProcessCHeapInfo > > it = gap.entrySet().iterator();

jinjiajie 2007-10-11
  • 打赏
  • 举报
回复
Multiple markers at this line
- Type mismatch: cannot convert from
Iterator<Map.Entry<String,RuntimeMonitor.ProcessCHeapInfo>> to
Iterator<RuntimeMonitor.ProcessCHeapInfo>
- Iterator is a raw type. References to generic type Iterator<E> should be
parameterized

错误信息
jinjiajie 2007-10-11
  • 打赏
  • 举报
回复
而且....编译器还是报错...类型完全不匹配了...
jinjiajie 2007-10-11
  • 打赏
  • 举报
回复
能解释下为什么这么改么?
shadao 2007-10-11
  • 打赏
  • 举报
回复

Map <String, RuntimeMonitor.ProcessCHeapInfo > gap = rt.getCHeap();
Iterator<RuntimeMonitor.ProcessCHeapInfo> it = gap.entrySet().iterator();




搞定

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧