File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Stacks Need Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Stacks Need Help" Watch "Stacks Need Help" New topic

Stacks Need Help

Alan Green

Joined: Sep 07, 2003
Posts: 17
Say if i have created two different stacks,and any integer over 10 goes in one stack(bigStack). If less than 10 goes in one stack(theStack). The program is already working where it will resize if its full,but I am trying to put the integers in the right Stack. This is what I have so far.

[ Jess added UBB [code] tags to preserve whitespace, check 'em out! ]
[ September 23, 2003: Message edited by: Jessica Sant ]
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Hi Joe,
I find it really hard to believe that you could understand the program above, but still need to ask this question. It's important to take the time to read and understand code the code you're working with; you're not going to learn anything otherwise.
That said, in a loop near the end of the program, you're reading each line, parseInt()-ing it, and pushing it onto a stack. All you need to do is use an "if" statement to choose between the two stacks -- i.e., "if (next < 10) ... else ..."
[ September 22, 2003: Message edited by: Ernest Friedman-Hill ]

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Stacks Need Help
It's not a secret anymore!