1. 程式人生 > >List 根據下標刪除元素

List 根據下標刪除元素

Object[] inPa = { "9527", "201712", "201711", "255451"};
List inpal = Arrays.asList(inPa);
Object[] de= {1,2};
List del= Arrays.asList(inPa);//需要刪除的下標
List<Object> outPa = new ArrayList<Object>();
for (int i = 0; i < inpal.size(); i++) {
    if(de.contains(i)){

    }else{
        outPa.add(inpal.get
(i)); } } System.out.println("刪除後的List : " + outPa.toString());