七九九
2016-02-28 14:29
public void testRemove(){
Course cr=(Course)coursesToSelect.remove(4);
System.out.println("我是课程:"+cr.id+":"+cr.name+",我即将被删除。");
System.out.println("成功删除课程。");
testGet();
}
remove()返回值是被删除的元素。
大家应该看仔细文档说明啊。
remove返回值是Boolean类型,
return:true if this list contained the specified element
如果List中含有这个要删除的元素那就返回true。否则返回false。。。。
remove()方法是void类型,是不需要返回值的,但是testGet()方法要有返回值
Java入门第三季
409776 学习 · 4546 问题
相似问题