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. awesome example
View Tutorial          By: jagjyot singh at 2010-01-12 20:39:04

2. buffer reader??????????????????
View Tutorial          By: sunil bisht at 2010-10-21 02:05:38

3. Thank u very much, your topic is very clear, to th
View Tutorial          By: Ahmed Samir at 2011-05-26 23:35:22

4. ya it is better one and more helpful while learni
View Tutorial          By: sumithkrishnank at 2011-07-16 06:47:37

5. Barely can understand it even I'm a NEWBIES ^^
View Tutorial          By: YieonChee at 2012-11-28 17:56:24

6. Thanks for providing this page it works with local
View Tutorial          By: Dharam Jaswal at 2012-02-02 13:19:24

7. I am using my NOKIA 2700 via blutooth connection.
View Tutorial          By: Rahi at 2010-05-11 04:39:33

8. HELP ME HOW TO ANALZE THE PROGRAM??????????
View Tutorial          By: MICHELLE FLORES at 2009-01-21 23:24:52

9. thanku very much. it is a good examples for abstr
View Tutorial          By: rajesh at 2010-12-17 10:57:42

10. I want to know about all java application.
View Tutorial          By: Ahasan at 2009-04-10 09:42:48