LinkedList boolean offerLast(E e)method Example Program


Inserts the specified element at the end of this list.

Program

package com.candidjava;
import java.util.LinkedList;
/**
 * 
 * @author : mohan
 * @description :The java.util.LinkedList.offerLast(E e) method inserts the
 *              specified element at the end of this list.
 */
public class LinkedListOfferLast {
	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.offerLast("SIVA");
		System.out.println("LinkedList:" + list);
	}
}

Output

LinkedList:[anandh, hari, vinoth, mohan, kamal]
LinkedList:[anandh, hari, vinoth, mohan, kamal, SIVA]

Explanation

public boolean offerLast(E e)
Inserts the specified element at the end of this list.
Specified by:
offerLast in interface Deque<E>
Parameters:
e - the element to insert
Returns:
true (as specified by Deque.offerLast(E))
Since:
1.6


Related Post

Comments


©candidjava.com