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. I am getting the following exception
Error

View Tutorial          By: Balraj Selvakumar at 2008-10-14 03:12:20

2. Sir , I am doing MSc(swe) . I want to know more ab
View Tutorial          By: guru prakash at 2009-10-15 09:10:05

3. Hello Ramlak, I am too getting
java.lang.U

View Tutorial          By: Amruta at 2008-11-07 23:56:17

4. i want to knew about byte datatype. why did not by
View Tutorial          By: pankaj kr tiwari at 2011-12-02 04:37:43

5. Thanks for the post !
View Tutorial          By: percy at 2011-11-24 08:56:23

6. how to connect jdbc in java on mysql
View Tutorial          By: naseem at 2011-10-26 19:26:45

7. nice effort
View Tutorial          By: Tiger at 2011-07-06 02:17:13

8. Thank you! This article helped me to solve this pr
View Tutorial          By: Stan Devyatovsky at 2008-09-12 05:20:20

9. I am not found a J2ME file for playing a audio pla
View Tutorial          By: S.M. ASHIQUER RAHMAN at 2008-11-22 22:33:43

10. Good
View Tutorial          By: sandesh at 2009-10-01 01:15:29