classStack {LinkedList<Integer> storage =newLinkedList<>();// Push a new item into the stackpublicvoidpush(int x) {storage.add(x); }// Pop the top of the stackpublicvoidpop() {storage.removeLast(); }// Return the top of the stackpublicinttop() {returnstorage.peekLast(); }// Check the stack is empty or not.publicbooleanisEmpty() {returnstorage.isEmpty(); } }