public
E peekLast()
Retrieves,
but does not remove, the last element of this list, or returns null
if this list is empty.
import java.util.*; class LinkedListPeekLast{ public static void main(String args[]){ LinkedList<Integer> myList; myList = new LinkedList<> (); /* Add Elements to myList */ myList.offerLast(10); myList.offerLast(20); myList.offerLast(30); myList.offerLast(40); System.out.print("Last Element of myList is "); System.out.println(myList.peekLast()); } }
Output
Last Element of myList is 40
No comments:
Post a Comment