LinkedList.removeLastOccurrence(Object o) has the following syntax.
public boolean removeLastOccurrence(Object o)
In the following code shows how to use LinkedList.removeLastOccurrence(Object o) method.
import java.util.LinkedList; /*from w ww . ja v a2s. co m*/ public class Main { public static void main(String[] args) { LinkedList<String> list = new LinkedList<String>(); // add some elements list.add("Hello"); list.add("tutorial"); list.add("from java2s.com"); list.add("Hello"); // print the list System.out.println("LinkedList:" + list); // remove the last "Hello" boolean found = list.removeLastOccurrence("Hello"); System.out.println("Element found:" + found); // print the list System.out.println("LinkedList:" + list); } }
The code above generates the following result.