On Thursday, Aug 14, 2003, at 13:25 Europe/London, Jason Dillon wrote:

If the list should not be mutable, then it makes more sense to return an Iterator (or ListIterator as mentioned), else someone could violate the contract and insert random fluff into the list instead of using the add/remove methods.

There are things you can do with an immutable list that you can't do with an (List)Iterator. One of them is to find out how big it is (using .size()), another is to add the contents into a new collection( new ArrayList(list)), for example.


Whether those methods are needed or not is debatable, but at least if you get the (immutable) list, then you can get the Iterator, ListIterator, size, xxxx etc.

Alex.



Reply via email to