The java.util.LinkedList.push() method is used to push an element at the starting(top) of the stack represented by LinkedList. This is similar to the addFirst() method of LinkedList and simply inserts the element at the first position or top of the linked list.
Parameters: The method accepts one parameter element of object type and represents the element to be inserted. The type ‘Object’ should be of same Stack represented by the LinkedList.
Return Type: The return type of the method is void i.e. it doesn’t returns any value.
Below programs illustrate the java.util.LinkedList.push() method:
[GeeksforGeeks, Like, I]
Program 2 :
[10, 20, 30]
- Stack push() Method in Java
- ArrayDeque push() Method in Java
- LinkedBlockingDeque push() method in Java
- LinkedList add() Method in Java
- LinkedList pop() Method in Java
- LinkedList set() Method in Java
- LinkedList contains() Method in Java
- LinkedList get() Method in Java
- BlockingDeque push() method in Java with examples
- ConcurrentLinkedDeque push() method in Java with Examples
- LinkedList remove() Method in Java
- LinkedList removeLast() Method in Java
- LinkedList spliterator() method in Java
- LinkedList getFirst() Method in Java
- LinkedList removeFirstOccurrence() Method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.