@@ -0,0 +1,900 @@
+package others.datastructure;%0A%0Aimport org.junit.jupiter.api.Assertions;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.EmptyStackException;%0A%0A/**%0A */%0Apublic class MyStack%3CT%3E extends ArrayList%3CT%3E %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        MyStack%3CInteger%3E stack = new MyStack%3C%3E();%0A        stack.push(1);%0A        stack.push(2);%0A        Assertions.assertEquals(2, stack.peek().intValue());%0A        stack.push(3);%0A        Assertions.assertEquals(3, stack.pop().intValue());%0A        Assertions.assertEquals(2, stack.pop().intValue());%0A        Assertions.assertEquals(1, stack.pop().intValue());%0A    %7D%0A%0A    public void push(T num) %7B%0A        add(num);%0A    %7D%0A%0A    public T pop() %7B%0A        if (isEmpty()) throw new EmptyStackException();%0A        return remove(size() - 1);%0A    %7D%0A%0A    public T peek() %7B%0A        if (isEmpty()) throw new EmptyStackException();%0A        return get(size() - 1);%0A    %7D%0A%7D%0A

Implement Stack