package com.atguigu.exercise;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
/**
* @author Dxkstart
* @create 2021-05-20 19:20
*/
public class ListExer {
/*
区分list中remove(int index) 和 remove(Object obj)
*/
@Test
public void testListRemove(){
List list = new ArrayList();
list.add(1);
list.add(2);
list.add("MM");
updateList(list);
// System.out.println(list);//[1,2]
for(int i = 0;i < list.size();i++){
System.out.println(list.get(i));//1,2
}
}
private static void updateList(List list) {
list.remove(2);//这删的是索引位置是2的数据
// list.remove(new Integer(2));//这删的是数据"2"
}
}