The java.util.concurrent.LinkedList.removeLastOccurrence() method is an inbuilt method in Java which accepts a parameter and removes the last appearance of that element in the list. Thus, in case the element is not present in the list, it remains unchanged.
public boolean removeLastOccurrence(Object o)
Parameters: The function accepts an object elem as parameter which denotes the object whose last appearance from the list is to be removed.
Return Value: The function returns true if elem is present in th list and returns false otherwise.
Below programs illustrate the use of removeLastOccurrence() method :
LinkedList: [GFG, Geeks, Gfg, gfg, Geeks] Removed last occurrence of 'Geeks' from the list LinkedList: [GFG, Geeks, Gfg, gfg]
LinkedList: [12, 280, 12, 1050, 12] Removed last occurrence of '12' from the list LinkedList: [12, 280, 12, 1050]
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- LinkedBlockingDeque removeLastOccurrence() method in Java
- ArrayDeque removeLastOccurrence() Method in Java
- ConcurrentLinkedDeque removeLastOccurrence() Method in Java
- BlockingDeque removeLastOccurrence() method in Java with Examples
- LinkedList toArray() method in Java with Example
- Java.util.LinkedList.peek() , peekfirst(), peeklast() in Java
- Java.util.LinkedList.offer(), offerFirst(), offerLast() in Java
- Java.util.LinkedList.get(), getFirst(), getLast() in Java
- Java.util.LinkedList.indexOf(), lastIndexof() in Java
- Java.util.LinkedList.poll(), pollFirst(), pollLast() with examples in Java
- LinkedList removeFirst() Method in Java
- LinkedList add() Method in Java
- LinkedList getFirst() Method in Java
- LinkedList getLast() Method in Java
- LinkedList clear() Method in Java
- LinkedList addFirst() Method in Java
- LinkedList addLast() Method in Java
- LinkedList addAll() Method in Java
- LinkedList set() Method in Java
- LinkedList remove() Method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nidhi_biet