Results 1 to 2 of 2
  1. #1
    vmcg105 is offline Member
    Join Date
    Mar 2008
    Posts
    3
    Rep Power
    0

    Default Help with queue array please!!

    Could someone please point me in the right direction. I am creating a queue array of customers. I have highlighted the code I am having problems with when trying to intalize the Queue, really cant get around this, any help?



    class QueueCustomer{
    final int MAXSIZE=5;
    Customer queue[] = Customer [MAXSIZE];// Array called queue. Can store up to 5 customers
    int qhead;
    int qtail;
    int qnoElements;

    //Construct the queue
    QueueCustomer(){
    for(Customer tmpCustomer:queue)
    tmpCustomer = ' ';

    qhead = 0; /* head initialised to 0 to point to start of queue.*/
    qtail = -1; /* tail initialised to -1 as the is no end of queue.*/
    qnoElements = 0; /* noElements initialised to 0-No elements on queue.*/
    }

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    10

    Default

    Check out the third–from–last sentence, "Similarly it is not ...", at the bottom of this page in the javadocs guide The For-Each Loop.
    Java Code:
    public class Test {
        public static void main(String[] args) {
            String[] strs = new String[5];
            int count = 0;
            for(String s : strs) {
                System.out.println("count = " + count++);
                s = "alfred e neuman";
            }
            for(String s : strs)
                System.out.println(s);
            System.out.println("----------------");
            for(int j =0; j < strs.length; j++)
                strs[j] = "tally ho";
            for(String s : strs)
                System.out.println(s);
        }
    }

Similar Threads

  1. Queue data structure
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-14-2008, 08:35 PM
  2. How to implement Priority queue with Java
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-12-2008, 08:49 PM
  3. Array Help
    By bluegreen7hi in forum New To Java
    Replies: 2
    Last Post: 03-28-2008, 03:25 AM
  4. Declaring a Queue
    By rhm54 in forum New To Java
    Replies: 1
    Last Post: 03-21-2008, 06:02 AM
  5. Using a queue
    By Krmeus in forum New To Java
    Replies: 0
    Last Post: 12-10-2007, 04:38 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
  •