LinkedList boolean removeLastOccurrence(Object o) method Example Program
By candid | Posted :
Jun 30, 2015
| Updated :
Jun 30, 2015
Removes the last occurrence of the specified element in this list (when traversing the list from head to tail). If the list does not contain the element, it is unchanged.
Program
package com.candidjava;
import java.util.LinkedList;
/**
*
* @author : mohan
* @description :The java.util.LinkedList.removeLastOccurrence(Object o) method
* removes the last occurrence of the specified element in this
* list (when traversing the list from head to tail). If the list
* does not contain the element, it is unchanged.
*/
public class LinkedListRemovLastOccur {
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");
list.add("vinoth");
System.out.println("LinkedList:" + list);
boolean found = list.removeLastOccurrence("vinoth");
System.out.println("Element found:" + found);
System.out.println("LinkedList:" + list);
}
}
Removes the last occurrence of the specified element in this list (when traversing the list from head to tail). If the list does not contain the element, it is unchanged.
Specified by:
removeLastOccurrence in interface Deque<E>
Parameters:
o - element to be removed from this list, if present