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. really this introduction makes me very interesting
View Tutorial          By: Himaja Reddy at 2012-11-09 06:57:31

2. ahmm I guess This is a VB6 program? or how can I g
View Tutorial          By: kelvin at 2011-02-27 14:07:44

3. nice explainations for the beginners like me :)
View Tutorial          By: Divya Taneja at 2012-02-11 13:17:17

4. how to return the boolean value. what is the data
View Tutorial          By: karthick at 2013-02-07 10:21:28

5. is it possible to change the increment variable?
View Tutorial          By: Lundi at 2013-04-08 21:21:13

6. Good example thank you so much
View Tutorial          By: Albadri at 2011-05-14 15:48:17

7. Hi Rajita, in accordance to our 'Privacy Policy' w
View Tutorial          By: webmaster at 2008-03-25 18:49:39

8. thats good
View Tutorial          By: P.Kumar at 2009-08-02 10:48:48

9. If I want to read input from A PDF what should I d
View Tutorial          By: thiru at 2015-08-12 10:57:51

10. I have maked all you said and when I open jsp I am
View Tutorial          By: ismail at 2011-03-16 04:08:53