您的位置:首页 > Web前端

java.util.LinkedList<E>中offer和add的区别

2017-12-04 11:13 344 查看


offer

public boolean offer(E e)


Adds the specified element as the tail (last element) of this list.

Specified by:
offer
 in interface 
Deque<E>

Specified by:
offer
 in interface 
Queue<E>

Parameters:
e
 - the element to add
Returns:
true
 (as specified by 
Queue.offer(E)
)


add

public boolean add(E e)


Appends the specified element to the end of this list.
This method is equivalent to 
addLast(E)
.

Specified by:
add
 in interface 
Collection<E>

Specified by:
add
 in interface 
Deque<E>

Specified by:
add
 in interface 
List<E>

Specified by:
add
 in interface 
Queue<E>

Overrides:
add
 in class 
AbstractList<E>

Parameters:
e
 - element to be appended to this list
Returns:
true
 (as specified by 
Collection.add(E)
)

参考:https://docs.oracle.com/javase/7/docs/api/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  LinkedList