DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   Java (http://www.daniweb.com/forums/forum9.html)
-   -   solvetion of my code. (http://www.daniweb.com/forums/thread14454.html)

shantuli Nov 22nd, 2004 9:26 pm
solvetion of my code.
 
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

jwenting Nov 23rd, 2004 2:10 am
Re: URGENT : solvetion of my code.
 
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


All times are GMT -4. The time now is 2:21 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC