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 appreciate, after a long time, I am able to
View Tutorial          By: Senthil at 2012-09-16 06:03:15

2. It is simply good and more informative
View Tutorial          By: ARUNA at 2011-06-19 06:32:29

3. http://www.java-samples.com/showtutorial.php?tutor
View Tutorial          By: Prab at 2009-04-13 11:54:17

4. i want to get the SCJP ceretificate plz anybody ca
View Tutorial          By: arpita kotadia at 2012-09-01 06:50:03

5. That was very nice yaar.
View Tutorial          By: sana at 2014-02-21 09:20:34

6. Perfectly working, and able to connect database.
View Tutorial          By: satyajit at 2012-06-01 20:16:53

7. I got the sample and the test working. Thanks a lo
View Tutorial          By: Trishul at 2009-10-26 07:32:57

8. how to trim in jsp page and to send the trimed con
View Tutorial          By: monishaa at 2015-07-16 10:06:11

9. I have a website and i want to make a option to se
View Tutorial          By: rasel at 2011-11-26 15:50:49

10. thanks a lot..please tell me how to implement this
View Tutorial          By: agnas at 2008-04-26 12:26:52