如何删除ArrayList里面的所有元素?也就是清空ArrayList?

解决方案 »

  1.   

    clear() //  Removes all of the elements from this list.
      

  2.   

    clear() //  Removes all of the elements from this list.
      

  3.   

    直接设置为null 有什么问题吗?Clear() 方法无非是把ArrayList中的每个元素设置为null,size设置为0。
      

  4.   

    ps:笔误,上面的Clear() 应该是 clear(),java方法一般是小写字母开头。
      

  5.   

    ArrayList paraList = new ArrayList();
    paraList.add(new Parameter(Integer.parseInt(id)));
    paraList.clear(); //清空ArrayList