编程语言
首页 > 编程语言> > Java 队列的`add()`方法和`offer()`方法的区别

Java 队列的`add()`方法和`offer()`方法的区别

作者:互联网

查阅API文档,找到

add():增加一个元素。如果队列已满,则抛出一个IIIegaISlabEepeplian异常

Inserts the specified element at the tail of this queue. As the queue is unbounded, this method will never throw IllegalStateException or return false.

offer():添加一个元素并返回true。如果队列已满,则返回false

Inserts the specified element at the tail of this queue. As the queue is unbounded, this method will never return false.

分析

标签:false,offer,队列,unbounded,queue,add,Java
来源: https://www.cnblogs.com/melodyjerry/p/13018920.html