按索引位置刪除元素的方法也可以獲取刪除元素
public?void?testRemove(){ ??????????Course?cr=(Course)coursesToSelect.remove(4); ??????????System.out.println("我是課程:"+cr.id+":"+cr.name+",我即將被刪除。"); ??????????System.out.println("成功刪除課程。"); ??????????testGet(); } remove()返回值是被刪除的元素。
2016-06-19
大家應(yīng)該看仔細文檔說明啊。
remove返回值是Boolean類型,
return:true if this list contained the specified element
如果List中含有這個要刪除的元素那就返回true。否則返回false。。。。
2016-02-28
remove()方法是void類型,是不需要返回值的,但是testGet()方法要有返回值