Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Lists;
- public class Stack<Thing> {
- Node<Thing> first;
- public Stack() {
- first = null;
- }
- public void push(Thing thing){
- this.first = new Node<Thing>(thing, first);
- }
- public Thing pop(){
- Node<Thing> temp = first.getNext();
- this.first = temp;
- return first.getObject();
- }
- public Thing peek(){
- return first.getObject();
- }
- }
Add Comment
Please, Sign In to add comment