I'm looking through the Java 8 documentation for LinkedList
, and I see several methods that appear to do the same thing. For example:
- add(E e): Appends the specified element to the end of this list.
- addLast(E e): Appends the specified element to the end of this list.
- offer(E e): Adds the specified element as the tail (last element) of this list.
These three appear to all do the same thing. I see that add
and offer
both return booleans signifying whether the modification was successful or not.
The docs for add
even say it is the same as addLast
, although it doesn't return anything. I guess I'm wondering why all this redundancy? When would I choose one over the other?