Resolution: Won't Fix
Name: diC59631 Date: 06/26/98
In the comments preceeding the List interface one can find
It is not inconceivable that someone might wish to implement a List that prohibits
This conceivable :) case would be very useful in our application
though there is one little problem. All methods, such as add()
addAll, remove(), removeAll, retainAll, etc. return a boolean value
to indicate if the underlying collection has been modified or not.
All but one: add(int, Object). This one returns void. As a consequence
we have two choices: either quietly ignore duplicates, or throw a runtime
exception. A preferred, though not valid option, would be to return
the index to the location where the element has been either added
or found. Thus if, say add(4, "Hello") returns 4 we know that
there is no duplicate and the element has been added successfully.
On the other hand if add(4, "Hello") returns, say, 11, we know that
this object was already in the list and is located at position 11. To
put it shortly, could you please change the signature of the add(int, Object)
int add(int index, Object element)
Thanks in advance!
(Review ID: 34375)