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



Ask a Question

Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. Thanks for giving this basic example of Abstract c
View Tutorial          By: Yogendra Kirar at 2010-08-07 07:48:34

2. thanks. worked.
View Tutorial          By: che at 2010-03-10 11:29:10

3. Hello friends can anybody tell me how to assign in
View Tutorial          By: gnvkdramesh at 2010-09-10 04:27:46

4. how can we split 12+12 into three tokens like 12,+
View Tutorial          By: arjun at 2012-11-26 11:07:24

5. thank for your article it helps us to our studies
View Tutorial          By: shane at 2010-07-21 19:12:22

6. Excellent Article.
View Tutorial          By: Praveen Kumar S at 2011-03-24 23:14:44

7. thanks really usefull
View Tutorial          By: MATHEW at 2012-06-29 00:55:57

8. Dude, you made my day.
View Tutorial          By: Sebasti├ín at 2011-08-29 14:01:10

9. Fantastic yaar .realy very good n simple example..
View Tutorial          By: Satya at 2012-10-11 09:33:17

10. Its very useful to me
View Tutorial          By: suba at 2011-07-04 11:21:19