Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Write a description of class Stack here.
- *
- * @Samuel Berkat Hulu
- * @Version 5.0
- */
- 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 int count()
- {
- return list.size();
- }
- public Object peek()
- {
- return list.get(currentIndex);
- }
- public void clear()
- {
- list.clear();
- currentIndex=-1;
- }
- public static void main(String[] args)
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement