LinkedList里的方法及其作用
push:
/**
* Pushes an element onto the stack represented by this list. In other
* words, inserts the element at the front of this list.
*
* <p>This method is equivalent to {@link #addFirst}.
*
* @param e the element to push
* @since 1.6
*/
public void push(E e) {
addFirst(e);
}
offer:
/**
* Adds the specified element as the tail (last element) of this list.
*在集合序列单排序后把指定元素添加到最后一个位置。
* @param e the element to add
* @return {@code true} (as specified by {@link Queue#offer})
* @since 1.5
*/
public boolean offer(E e) {
return add(e);
}
books.push("a"); //把a元素插入到集合中,从0开始;
offerFirst:
/**
* Inserts the specified element at the front of this list.
*在集合序单中的最前面插入指定元素。
*
* @param e the element to insert
* @return {@code true} (as specified by {@link Deque#offerFirst})
* @since 1.6
*/
public boolean offerFirst(E e) {
addFirst(e);
return true;
}