Is the LinkedList Java API redundant?

Are the add , addLast , offer and offerLast in the LinkedList Java class the same? If so, why does the design of the API reduce the multiplicity for redundancy?

+6
source share
1 answer

The LinkedList class implements the List and Deque . So the class must implement these four methods, although you are right, they do the same.

By the way, LinkedList not an API. If you use an interface, for example

 List<String> list = new LinkedList<>(); 

then you will not see the addLast , offer and offerLast .

+12
source

Source: https://habr.com/ru/post/943524/


All Articles