Stack:(List interface)
Stack Class Is part of collection framework and it is
available in “java.util” package.
The Stack class extends the Vector class.
In stack, elements are stored and accessed in LIFO manner last-in-first-out
i.e., elements are added to the top of the stack and removed from the top of
the stack.
To add an element to the top of the stack, we use the push()
method.
To remove an element from the top of the stack, we use the
pop() method.
The peek() method returns an object from the top of the
stack.
Creation of Stack:
Stack st=new Stack( );
Java Code:
No comments:
Post a Comment