LinkedList boolean offer(E e) method Example Program
By candid | Posted :
Jun 30, 2015
| Updated :
Jun 30, 2015
Adds the specified element as the tail (last element) of this list.
Program
package com.candidjava;
import java.util.LinkedList;
/**
*
* @author : mohan
* @description :The java.util.LinkedList.offer(E e) method adds the specified
* element as the tail (last element) of this list.
*/
public class LinkedListOffer {
public static void main(String[] args) {
LinkedList list = new LinkedList();
list.add("anandh");
list.add("hari");
list.add("vinoth");
list.add("mohan");
list.add("kamal");
System.out.println("LinkedList:" + list);
list.offer("Karthick");
System.out.println("LinkedList:" + list);
}
}
Output
LinkedList:[anandh, hari, vinoth, mohan, kamal]
LinkedList:[anandh, hari, vinoth, mohan, kamal, Karthick]
Explanation
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))
Since:
1.5
Related Post
Comments