pollLast() method

pollLast(): This polllast method in java is used to removes and return the last element from LinkedList. Its return type is E. It Retrieves the element and also removes it from LinkedList.

E pollLast();

Where, E represents the type of elements in LinkedList.
return null, if this LinkedList is empty.

import java.util.LinkedList;
public class ExampleOfLinkedList 
	public static void main(String[] args) 
		LinkedList<String> listOfNames = new LinkedList<String>();
	        // It returns the element present at first position
	        System.out.println("Element present at first position is = 

Output: Element present at first position is = RAVI

Leave a Comment

Follow us on Instagram & watch the latest videos on YouTube. Click below social icons to visit our Instagram & YouTube profiles.