public
boolean offerLast(E e)
Inserts
the specified element at the end of this list.
import java.util.*; class LinkedListOfferLast{ 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.println("Elements in myList are"); System.out.println(myList); } }
Output
Elements in myList are [10, 20, 30, 40]
No comments:
Post a Comment