1 import java.util.ArrayList; 2 3 public class MyStack { 4 5 private ArrayList<Object> arrayList; 6 7 public MyStack() { 8 arrayList = new ArrayList<>(); 9 } 10 11 public void pop(Object o) { 12 arrayList.add(o); 13 } 14 15 public Object myRamove() { 16 int size = arrayList.size(); 17 if (size > 0) { 18 return arrayList.remove(arrayList.size() - 1); 19 }else { 20 return -1; 21 } 22 } 23 public int getSize() { 24 return arrayList.size(); 25 } 26 27 }