There is a method
removeRange
in AbstractList
class, somehow it is protected
.
So, if you want to remove a range from a Vector, use subList
(which is come from List
) instead:
v.subList( 0, 12 ).clear();The
subList
method returns a view(or a snapshot) instead of a copy to manipulates original container.
So if you want to do any operation in specific range, use subList
.
v.removeAll(v.subList(0,12));
回覆刪除這樣呢?
by overing
應該也是可以吧,我對 Java 不熟 orz
回覆刪除我猜它 return 一個 reference 的好處是可以做其他 vector 沒提供的操作