Advertisement
Aldin-SXR

push()

Mar 5th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.24 KB | None | 0 0
  1. /* Push an item onto the stack */
  2. public void push(Item item) {
  3.     Node<Item> newNode = new Node<Item>();  // 1
  4.     newNode.data = item;                    // 1
  5.     newNode.next = top;                     // 2
  6.     top = newNode;                          // 3
  7.     length++;                               // 4
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement