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. Can you please send me the full code in sending an
View Tutorial          By: jen at 2008-05-28 00:22:21

2. Hi I need code examples J2ME for chating aplicatio
View Tutorial          By: agus at 2010-04-03 04:16:11

3. Hi dude's it's working fine for me.first i got no
View Tutorial          By: raavi.surendra at 2011-11-16 10:10:31

4. can anybode tell me how can i make my own bluetoot
View Tutorial          By: Prasenjit at 2013-10-11 06:57:13

5. Hi all people...If i need to read a sms from the m
View Tutorial          By: Omarsi12 at 2009-09-06 17:11:15

6. hi i have used this code in my site. and it says <
View Tutorial          By: Jawad at 2011-01-16 06:31:00

7. To install 32 bit java Communication API you can f
View Tutorial          By: Shailendra at 2013-04-06 14:49:44

8. what if the delimiter is "(quotation mark)?
View Tutorial          By: hiakoto at 2013-02-18 16:15:20

9. Thanks for the Information. Its very useful
View Tutorial          By: Husain at 2009-03-04 13:30:38

10. i need help for my study, i need an algorithm for
View Tutorial          By: Vincent at 2011-08-17 13:37:52