package exp8; import java.util.LinkedList; public class MyList { private LinkedList list; public MyList(){ list = new LinkedList<>(); } public void show(){ System.out.print("["); for(E e :list){ System.out.print(e+","); } System.out.println("\b]\n"); } public void push(E elem){ list.add(elem); System.out.println("Push(" + elem +")"); show(); } public E pop(){ E elem = list.removeLast(); System.out.println("Pop(" + elem +")"); show(); return elem; } public static void main(String[] args) { MyList list = new MyList<>(); list.push(1); list.push(2); list.push(3); list.pop(); list.push(4); } }