How to read last element from LinkedList? How to read last element from LinkedList Below example shows how to read last element from LinkedList. LinkedList provides few methods to read last element, those methods are:

app conocer gente android check out this site getLast(): Returns the last element in this list.
crГ©er site de rencontre avec joomla peekLast(): Retrieves, but does not remove, the last element of this list, or returns null if this list is empty.

Continue Reading package linkedlist; import java.util.LinkedList; public class LastElementLinkedList { public static void main(String[] args) { LinkedList<String> arrl = new LinkedList<String>(); arrl.add("First"); arrl.add("Second"); arrl.add("Third"); arrl.add("Random"); System.out.println("Last Element: "+arrl.getLast()); System.out.println("Last Element: "+arrl.peekLast()); } }

content Output:

Last Element: Random
Last Element: Random