//LinkedList Example Program for removeLastOccurrence(Object o) /** * @author candidjava.com * @description: 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. */ import java.util.LinkedList; public class List2 { public static void main(String args[]) { LinkedList l = new LinkedList();// create object for linkedlist. l.add("e"); l.add("f"); l.add("d");// add elements in list. l.add("s"); l.add("s"); l.add("d"); System.out.println("Before removing" + l); l.removeLastOccurrence("s");// this function used for Removes the last // occurrence of the specified element in // list. System.out.println("after removing" + l); } } <span style="color: #3366ff;">Output:</span> Before removing[e, f, d, s, s, d] after removing[e, f, d, s, d]
Output:
Before removing[e, f, d, s, s, d]
after removing[e, f, d, s, d]
BACK