Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-08-2008, 07:13 PM
Member
 
Join Date: Mar 2008
Posts: 3
vmcg105 is on a distinguished road
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.*/
}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-08-2008, 08:03 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,022
hardwired is on a distinguished road
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.
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); } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Queue data structure Java Tip java.lang 0 04-14-2008 09:35 PM
How to implement Priority queue with Java Java Tip java.lang 0 04-12-2008 09:49 PM
Array Help bluegreen7hi New To Java 2 03-28-2008 03:25 AM
Declaring a Queue rhm54 New To Java 1 03-21-2008 06:02 AM
Using a queue Krmeus New To Java 0 12-10-2007 04:38 PM


All times are GMT +3. The time now is 01:04 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org