| | |
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 |
actuate android api applet application applications array arrays automation balls bank binary bluetooth business chat class classes clear client code codesnippet collections component coordinates database defaultmethod development dice dragging ebook eclipse educational error formatingtextintooltipjava fractal game givemetehcodez graphics gui hql html ide image infinite ingres input integer internet invokingapacheantprogrammatically j2me java javaprojects jni jpanel jtextarea julia linux list loop looping map method methods mobile mysql netbeans newbie openjavafx parameter php print problem program programming project recursion repositories scanner screen scrollbar server set size sms sort sorting sql sqlserver state storm string sun superclass swing swt text-file threads tree websites windows





