I would like to know what this tutorial means when it refers to the following bit of explanation. In particular the part which I highlighted in bold.
Insert
The
addfirst
andofferFirst
methods insert elements at the beginning of theDeque
instance. The methodsaddLast
andofferLast
insert elements at the end of theDeque
instance. When the capacity of theDeque
instance is restricted, the preferred methods areofferFirst
andofferLast
becauseaddFirst
might fail to throw an exception if it is full.
- Why would offerFirst be preferred?
- Why would addFirst fail to throw an exception if it is full? Should not it be better if it guaranteed to throw an exception in those circumstances?