public static void removeElem(Stack stack) {
Stack newStack = new Stack(7); //7 is a size of stack
int temp = stack.readTop();
int e;
newStack.push(temp); //we dont remove first element
while(!stack.isEmpty()) {
e = stack.pop();
if (e != temp) {
newStack.push(e);
}
}
while (!newStack.isEmpty()) {
e = newStack.pop();
stack.push(e);
}
}