Implementation Stack Using Array
Stack is a Linear Data Structure.Stack can be Implemented easily by using an array in Java .Every Stack has two Main Operations/Methods
a)Push-Used to Insert an Element to the Stack
b)Pop- Used to Remove an Element from the Stack
Code :
void push(int item)
{
if(top==n)
{
System.out.println("STACK IS FULL");
}
else
{
a[top]=item;
top++;
}
}
void pop()
{
if(top==0)
{
System.out.println("STACK EMPTY");
}
else
{
top--;
out=a[top];
}
Get the Complete Code from http://c-madeeasy.blogspot.com/2011/...structure.html
Re: Implementation Stack Using Array
You code..
1.doesn't check for exceptions properly. Integer.parseInt() throws NumberFormatException
2.violates sun java's naming conventions.
How can you expect something like this to be a learning example ?