Don't the methods add, addLast, offer and offerLast in the Java LinkedList class perform the same thing? If so, why does the API design trade off brevity for redundancy?
The LinkedList class implements the interfaces List and Deque. So the class needs to implement those four methods even though, you're right, they do quite the same.
By the way, the LinkedList is not the API. If you use an interface, like
List<String> list = new LinkedList<>();
for example, then you won't see the methods addLast, offer and offerLast.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With