import java.util.*;
class StackDemo
{
public static void main(String args[])
{ Stack<Integer> st = new Stack<Integer>();
System.out.println("stack: " + st);
st.push(42);
System.out.println("stack: " + st);
st.push(66);
System.out.println("stack: " + st);
st.push(99);
System.out.println("stack: " + st);
Integer io = st.pop();
System.out.println("stack: " + st);
io = st.pop();
System.out.println("stack: " + st);
io = st.pop();
System.out.println("stack: " + st);
try
{ st.pop();
}
catch (EmptyStackException e)
{ System.out.println("empty stack");
}
}
}
class StackDemo
{
public static void main(String args[])
{ Stack<Integer> st = new Stack<Integer>();
System.out.println("stack: " + st);
st.push(42);
System.out.println("stack: " + st);
st.push(66);
System.out.println("stack: " + st);
st.push(99);
System.out.println("stack: " + st);
Integer io = st.pop();
System.out.println("stack: " + st);
io = st.pop();
System.out.println("stack: " + st);
io = st.pop();
System.out.println("stack: " + st);
try
{ st.pop();
}
catch (EmptyStackException e)
{ System.out.println("empty stack");
}
}
}
Comments
Post a Comment