首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

ArrayList的remove()步骤失败

2012-09-07 
ArrayList的remove()方法失败MapString,Integer map new HashMapString,Integer()List list new

ArrayList的remove()方法失败

Map<String,Integer> map = new HashMap<String,Integer>();

List list = new ArrayList();

?

?

list.remove(map.get(key)); //remove失败,原因map.get(key)是一个object,还没有转为int类型,而这个object在list中是不存在的

?

正确方法

int index = map.get(key);

list.remove(index);

?

?

热点排行