异:
总结:当队列容量超过限制时,add()会报异常,offer()会返回false
1. add()API:
Inserts the specified element into this queue if it is possible to do soimmediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available.
- capacity restrictions: 容量限制
- if no space is currently available: 当前没有可用空间
Return:
true (as specified by Collection.add)
Throws: IllegalStateException - if the element cannot be added at thistime due to capacity restrictions
2. offer()API:
Inserts the specified element into this queue if it is possible to doso immediately without violating capacity restrictions.When using a capacity-restricted queue, this method is generallypreferable to add, which can fail to insert an element onlyby throwing an exception.
- capacity-restricted queue: 容量受限的队列
Return:
true if the element was added to this queue, else false



