Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By JosAH

Thread: Merging stacks using Util Stack

  1. #1
    trishtren is offline Member
    Join Date
    Feb 2011
    Posts
    53
    Rep Power
    0

    Default Merging stacks using Util Stack

    Hello, i was wondering if someone could tell me if there is a way to push an entire stack onto another stack. I looked google but cant find anything. Basically i want to take one stack and add all its contents in one go onto another stack.
    Last edited by trishtren; 11-08-2011 at 12:31 PM.

  2. #2
    trishtren is offline Member
    Join Date
    Feb 2011
    Posts
    53
    Rep Power
    0

    Default Re: Merging stacks using Util Stack

    Hello, i was wondering if someone could tell me if there is a way to push an entire stack onto another stack. I looked google but cant find anything. Basically i want to take one stack and add all its contents in one go onto another stack.
    Ie something like this, but this doesent work

    Java Code:
     Stack<box> BigBox= new Stack<box>();
     BigBox.push(littlebox); //try to add another stack<box> little box to the bigger box

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    12,996
    Blog Entries
    7
    Rep Power
    19

    Default Re: Merging stacks using Util Stack

    The Stack class extends the Vector class; the Vector class has addAll( ... ) methods.

    kind regards,

    Jos
    trishtren likes this.
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    trishtren is offline Member
    Join Date
    Feb 2011
    Posts
    53
    Rep Power
    0

Similar Threads

  1. Merging
    By GoodOldDany in forum Java Applets
    Replies: 3
    Last Post: 05-31-2011, 11:28 PM
  2. Demonstration of Stack class in java.util package
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-16-2008, 10:33 PM
  3. How to use Stack class in java.util package
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-16-2008, 10:32 PM
  4. Using java.util.Stack
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-20-2007, 05:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •