Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.List;
- public class Stack {
- private List<Object> list = new ArrayList<Object>();
- private int currentIndex = -1;
- public void push(Object object){
- list.add(object);
- currentIndex++;
- }
- public Object pop(){
- Object object = list.remove(currentIndex);
- currentIndex--;
- return object;
- }
- public Object peek(){
- return list.get(currentIndex);
- }
- public int count(){
- return list.size();
- }
Advertisement
Add Comment
Please, Sign In to add comment