Results 1 to 2 of 2
Thread: Help with queue array please!!
- 03-08-2008, 06:13 PM #1
Member
- Join Date
- Mar 2008
- Posts
- 3
- Rep Power
- 0
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.*/
}
- 03-08-2008, 07:03 PM #2
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
-
Queue data structure
By Java Tip in forum java.langReplies: 0Last Post: 04-14-2008, 08:35 PM -
How to implement Priority queue with Java
By Java Tip in forum java.langReplies: 0Last Post: 04-12-2008, 08:49 PM -
Array Help
By bluegreen7hi in forum New To JavaReplies: 2Last Post: 03-28-2008, 02:25 AM -
Declaring a Queue
By rhm54 in forum New To JavaReplies: 1Last Post: 03-21-2008, 05:02 AM -
Using a queue
By Krmeus in forum New To JavaReplies: 0Last Post: 12-10-2007, 03:38 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks