void addLast(E e) method Example Program


Appends the specified element to the end of this list.

Program

package com.candidjava;

import java.util.LinkedList;

/**
 * 
 * @author : mohan
 * @description :The java.util.LinkedList.addLast(E e) method inserts the
 *              specified element at the end of this list.
 */
public class LinkedListAddLast {
	public static void main(String[] args) {
		LinkedList list = new LinkedList();
		list.add("anandh");
		list.add("hari");
		list.add("vinoth");
		list.add("kamal");
		System.out.println("LinkedList:" + list);
		list.addLast("I am Last:-(  ");
		System.out.println("LinkedList:" + list);
	}
}

Output

LinkedList:[anandh, hari, vinoth, kamal]
LinkedList:[anandh, hari, vinoth, kamal, I am Last:-(  ]

Explanation

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

Specified by:
addLast in interface Deque<E>

Parameters:
e - the element to add


Related Post

Comments


©candidjava.com