• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hiding some elements of a queue

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, so I have this very simple, very inefficient program, but that's alright, the only thing that I would like to know is how to print the first five numbers of the queue as zeros without changing the values of ssn1 through ssn5. For example I would like to print 000001111, and not 111111111, but still have those values stored in the queue. Could someone help me with that? I simply would like to hide them.


 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so...you want to convert ssn into a string (you're doing this implicitly with your print statement), take a substring of it, and then print "00000" plus the substring? is that correct?
 
Tom Lindsey
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

fred rosenberger wrote:so...you want to convert ssn into a string (you're doing this implicitly with your print statement), take a substring of it, and then print "00000" plus the substring? is that correct?



Yes, I think so. Could I have an example?
 
Tom Lindsey
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is an update to my code. I can not figure out how to convert that queue of integers into a string.

 
fred rosenberger
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well...

You're newest code doesn't compile. It would make it easier for folks to help you if you would a) tell us that, and b) post what the compiler message is:

SSNQueue.java:42: error: no suitable method found for toString(Queue<Integer>)
Integer.toString(ssn);
^

But more importantly, you should StopCoding. sit down with pencil and paper, and figure out what you want to do, using English, not Java. Pretend you want to explain to a 10 year old child what needs to be done.

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic