Java list.remove( )方法需要注意的地方

List<Integer> integerList = new ArrayList<>();

当我们要移除某个Item的时候

remove(int position):移除某个位置的Item

remove(object object):移除某个对象

 

那么remove(12)到底是移除第12的item,还是移除内容为12的Item。

那就要看12到底是int类型还是Integer类型,如果是int类型那么就是移除第12的item,如果是第Integer类型,那么就是移除内容为12的Item。

 

猜你喜欢

转载自www.cnblogs.com/tangZH/p/9457044.html