solvetion of my code.

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2004
Posts: 16
Reputation: shantuli is an unknown quantity at this point 
Solved Threads: 0
shantuli shantuli is offline Offline
Newbie Poster

solvetion of my code.

 
0
  #1
Nov 22nd, 2004
hello,
i just start learning java.please solve my following problem:


Q: Write a simple program that allows a user to push up to ten names onto a stack as well as popping them off the stack.

my code is:

import DataStructures.*;

public class StackDemo {

public static void main(String[] args) {

stack a = new StackArray();

for (int i = 0; i < 10;i++) {
s.push(new Integer(i));
}

while (!s.isEmpty()) {

System.out.println(s.pop());
}
}
}


it is not running properly.other question is if i want to enable other data types such as an int, float, double and char to be pushed into the stack what changes do i need to make? and if i want to do the same program to a Queue what i have to do?

please try to solve my problem as soon as possible. it's urgent. thank you for helping me.

shantuli :o
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: URGENT : solvetion of my code.

 
0
  #2
Nov 23rd, 2004
if you hadn't said it was urgent I might have taken the time to help you along.
Claiming your problem is urgent is rude, it implies you consider yourself to be more important than anyone else here which you're not.

But I'll be nice and give a hint
Look at the API docs for java.util.Stack
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum


Views: 1486 | Replies: 1
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC