Stack in Java using array without stack class.
Java provides an inbuilt object type called Stack. It is a collection that is based on the last in first out (LIFO) principle. On Creation, a stack is empty.but I'm creating stack in this video manually without using stack class.
2. pop() Method : Removes and returns the top element of the stack.
3. Over Flow : Pushes element when stack is already completely fill.Then Overflow Exception is occur.
4. Under Flow : This shows when all elements are pop from the stack.then the stack is empty,so if we again pop the stack then Under flow is occur in program.
There is also so many built methods for set elements in stack and also retrieve element from the stack.In this lecture I'm defining my own pop() & push() methods for storing and retrieving elements from the stack.
1. push() Method : Pushes an element on the top of the stack.2. pop() Method : Removes and returns the top element of the stack.
3. Over Flow : Pushes element when stack is already completely fill.Then Overflow Exception is occur.
4. Under Flow : This shows when all elements are pop from the stack.then the stack is empty,so if we again pop the stack then Under flow is occur in program.
No comments:
Post a Comment