• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hiding some elements of a queue  RSS feed

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • 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.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!