St.Antario
St.Antario

Reputation: 27385

Deque's methods and the methods inherited from Queue

As stated in the Deque's javadoc, the Last-methods (addLast, removeLast, etc...) are totally equivalent to the Queue methods. So it's not clear to me why they declared the Last-methods in the Deque interface. Why wouldn't just use the Queue's methods in the Deque interface and declare the only First-methods?

Upvotes: 1

Views: 222

Answers (1)

Eran
Eran

Reputation: 393856

Calling addLast makes your intent clearer than add. Code that contains calls to addFirst and addLast is easier to understand than code that contains calls to addFirst add add.

Upvotes: 1

Related Questions