12-03-2010, 02:57 PM
Stack class is available in java. Stack is used which means that we have to define the type of E like integer,string etc and the stack will be intialised with the type of E only.
Code:
import java.util.*;
public class UsingStack{
public static void main(String args[])
{
Stack<String> stack = new Stack<String>();
stack.push("hello");
stack.push("world");
while(!stack.empty())
{
System.out.println(stack.pop());
}
}
}