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



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. Please guys i need sms.zip. I tried SMS.RAR but al
View Tutorial          By: Waseem at 2010-03-06 15:48:40

2. Thank you......
View Tutorial          By: Suvadip at 2013-04-19 05:11:51

3. Hi, these are the lines i added after i downloaded
View Tutorial          By: sandeep,p at 2012-11-22 10:17:07

4. Great ! done a gud job
View Tutorial          By: Manju at 2012-11-02 06:43:58

5. can i also get the variable description for this p
View Tutorial          By: Maya Rao at 2013-10-04 06:06:00

6. i don't use mysql,but oracle.
how to resolv

View Tutorial          By: Mike Zhu at 2009-06-23 19:20:06

7. plz answr for questions about time out problem whl
View Tutorial          By: rrai at 2013-08-26 06:06:57

8. Suppose we are executing a try block and faced an
View Tutorial          By: Suindu De at 2015-10-08 10:56:56

9. thanks a lot ya i got it.................
View Tutorial          By: sruthi at 2013-02-02 08:18:07

10. Gives a syntax error
View Tutorial          By: Siddharth at 2015-06-10 05:15:00