944,181 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1620
  • Java RSS
Nov 22nd, 2004
0

solvetion of my code.

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
shantuli is offline Offline
16 posts
since Jul 2004
Nov 23rd, 2004
0

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
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: IO and Embedded SQL
Next Thread in Java Forum Timeline: what is the problem with this app





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC