public
boolean offer(E e)
Adds
the specified element as the tail (last element) of this list.
Returns true if the element added successfully.
import java.util.*; class LinkedListOffer{ public static void main(String args[]){ LinkedList<Integer> myList; myList = new LinkedList<> (); /* Add Elements to myList */ myList.offer(10); myList.offer(20); myList.offer(30); myList.offer(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