Results 1 to 4 of 4
  1. #1
    jeanjiang is offline Member
    Join Date
    Apr 2011
    Posts
    10
    Rep Power
    0

    Default Java Stack and Queue

    From Data Construction, I learned two constructions - Stack and Queue. Stack is FILO and Queue is FIFO. My question is that in Java, if we want to use Stack and Queue, do we need to create two classes to implement there two functions?
    Last edited by jeanjiang; 04-25-2011 at 12:15 PM.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by jeanjiang View Post
    From Data Construction, I learned two constructions - Stack and Queue. Stack is FILO and Queue is FIFO. My question is that in Java, if we want to use Stack and Queue, do we need to create two classes to implement there two functions?
    I do hope that you have either downloaded or bookmarked the Java SE API documentation. If you have you'd see that those classes (not 'functions') are implemented for you.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by petarpass View Post
    algorithm of the structures of stack and queue etc is same ! language syntax will be different
    Please enlighten us; I'd be surprised (about the identical structure of both).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by jackycui View Post
    The java.util.Stack class deserves a little explanation on its own.
    I personally find the Stack<T> class a lousy implementation; the super class (a Vector<T>) is way too 'strong' to serve as a base class (see 'Programming by contract' by Bertrand Meyer (sp?))

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Replies: 6
    Last Post: 08-20-2010, 03:13 PM
  2. Java Stack Overflow?
    By fullmetaljacket in forum New To Java
    Replies: 0
    Last Post: 05-19-2009, 08:49 PM
  3. Computation Complexities for a stack, queue, and map?
    By daletron3030 in forum New To Java
    Replies: 0
    Last Post: 03-18-2009, 07:13 AM
  4. How to implement Priority queue with Java
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-12-2008, 09:49 PM
  5. Using java.util.Stack
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-20-2007, 06:17 PM

Tags for this Thread

Posting Permissions

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