Why is List.remove overloaded the way it is?

Viewed 491

Is there historical reasons to the two ambiguous List.remove?

It seems like terrible design to me.
For a List<Integer> it just seems really confusing.

EDIT:

Everybody seems pretty fine with this. Let me precise things a bit.

Let's say I have a List<Boolean>.

Integer idx = Integer.valueOf(2);
list.remove(idx)

Though idx is an object, Java compiles and will remove the item at index 2.

Now if it had been a List<Integer>, the very same code would have called a different method with a totally different behavior.

Let's not talk about what would happen with Generics.

I feel like different behavior implies different names is a precious rule, especially within the same class.

5 Answers
Related