| | |
queue question
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
When putting an item inside the queue why do you want to show the queue. Or is it some assignment requirement that on every addition of element to the queue you need to show the queue structure ?
If yes, then write some method that traverses the entire queue and shows the data stored ar every location of the list queue.
If not give us details.
If yes, then write some method that traverses the entire queue and shows the data stored ar every location of the list queue.
If not give us details.
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
•
•
Join Date: Sep 2008
Posts: 91
Reputation:
Solved Threads: 1
•
•
•
•
Or is it some assignment requirement that on every addition of element to the queue you need to show the queue structure ?.
•
•
•
•
If yes, then write some method that traverses the entire queue and shows the data stored ar every location of the list queue.
.
Java Syntax (Toggle Plain Text)
public String toString(){ String s = "[ "; if (front.info != null){ s += "( " + peek().toString() + " )" + " ]"; }else{ s += "]"; } return s; }
my prof. instructed me or siad to have an tostring method for that.. so i had the above. but it shows only the first element added to the queue.. what's wrong with it?
You need to traverse the queue entirely for that, currently you are just showing the info of the first node.
Do something like this :
Don't assume my code to be working, rather the opposite, just treat it as a pseudocode for the traversing and printing logic.
Do something like this :
java Syntax (Toggle Plain Text)
public void showQueue(myQueue head){ myQueue temp = head; while(temp != null){ System.out.println(temp.data.toString()); // prints out data at this node. temp = temp.next; // next should be the link to the next node } }
Don't assume my code to be working, rather the opposite, just treat it as a pseudocode for the traversing and printing logic.
Last edited by verruckt24; Jan 21st, 2009 at 7:57 am.
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
![]() |
Similar Threads
- Help on stack , queue, palindrome program... (C++)
- Please Help me in finding multiple choice question with answer on data structure. (Computer Science)
- Another question regarding memory (C)
- queue program question (C++)
- queue , memory, 32k please (C++)
- Program on Queue (C++)
- help with queue plz (C++)
- Homework Help!! Priority Queue ?? (Computer Science)
Other Threads in the Java Forum
- Previous Thread: Need help with Caesar Cipher program
- Next Thread: Specification for data transfer in j2me
| Thread Tools | Search this Thread |
911 addball addressbook android api append applet application array arrays automation binary bluetooth button character chat class classes client code component consumer css csv database eclipse ee error event exception fractal ftp game givemetehcodez graphics gui html ide image input integer j2me japplet java javaarraylist javaprojects jmf jni jpanel julia jvm key linked linux list loan loop map method methods mobile netbeans newbie objects oriented output panel phone print printf problem program programming project projects recursion replaydirector reporting researchinmotion robot rotatetext scanner screen se server service set size sms software sort sql string swing test threads transfer tree ubuntu windows





