+ 5

LinkedList Method

I would like to know the difference between .add() method and the .offer() method. Thanks!!

3rd May 2018, 3:37 AM
AntopixelăŠ™ïž
AntopixelăŠ™ïž - avatar
1 Answer
+ 9
Although they are very similar they aren't the same. There is a difference in the interfaces that are used within the methods, but the most substantial difference to you would be that if the add method can not add the item to the list an error will be thrown, whereas the offer method would not. The non-positional add method and the addLast method are however, the same.
3rd May 2018, 4:12 AM
ChaoticDawg
ChaoticDawg - avatar