Programming Tutorials

Comment on Tutorial - Stack example in Java - push(), pop(), empty(), search() By Henry



Comment Added by : hetal

Comment Added at : 2012-02-03 08:47:39

Comment on Tutorial : Stack example in Java - push(), pop(), empty(), search() By Henry
Hi Thanks for this example but i need more help for the following program:
int n = 4;
StackInterface<Integer> myStack = new LinkedStack<Integer>();
while (n > 0)
{
myStack.push(n);
n--;
} // end while

int result = 1;
while (!myStack.isEmpty())
{
int integer = myStack.pop();
result = result * integer;
} // end while
System.out.println("result = " + result);

a. What value is displayed when this code executes?

b. What mathematical function does the code evaluate?


View Tutorial