import
java.util.Stack;
public
class
StackImpl<E> {
private
Stack<E> stack;
public
StackImpl() { stack =
new
Stack<E>(); }
public
boolean
empty() {
return
stack.empty(); }
public
E peek() {
return
stack.peek(); }
public
E pop() {
return
stack.pop(); }
public
E push(E item) {
return
stack.push(item); }
public
int
search(Object o) {
return
stack.search(o); }
public
static
void
main(String args[])
{
StackImpl<String> stack =
new
StackImpl<String>();
System.out.println(
"element pushed : "
+ stack.push(
"one"
));
System.out.println(
"element pushed : "
+ stack.push(
"two"
));
System.out.println(
"element pushed : "
+ stack.push(
"three"
));
System.out.println(
"element pushed : "
+ stack.push(
"four"
));
System.out.println(
"element pushed : "
+ stack.push(
"five"
));
System.out.println(
"element popped : "
+ stack.pop());
System.out.println(
"element popped : "
+ stack.pop());
System.out.println(
"Element peek : "
+ stack.peek());
System.out.println(
"position of element three - "
+ stack.search(
"three"
));
while
(!stack.empty()) {
System.out.println(
"element popped : "
+ stack.pop());
}
}
}