Guest User

Untitled

a guest
Jun 19th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. package Lists;
  2.  
  3. public class Stack<Thing> {
  4.  
  5. Node<Thing> first;
  6.  
  7. public Stack() {
  8. first = null;
  9. }
  10.  
  11. public void push(Thing thing){
  12. this.first = new Node<Thing>(thing, first);
  13. }
  14.  
  15. public Thing pop(){
  16.  
  17. Node<Thing> temp = first.getNext();
  18. this.first = temp;
  19. return first.getObject();
  20. }
  21.  
  22. public Thing peek(){
  23. return first.getObject();
  24. }
  25. }
Add Comment
Please, Sign In to add comment