This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question

 
Stephen Foy
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, im writing a program that involves outputting the lyrics to the song "99 bits of bytes on the bus", im just wondering if theres a more effective way of putting this part of the code. Maybe into a string, to i dont have it looking all compacted together?

 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd put the decrementer on a line by itself for sure. Even experienced coders have to look twice when it's in a line with other stuff.

If you're in Java 5 look at PrintStream.printf() as a way to avoid all that concatenation. If you just want to make it look neater and fit in a decent margin, you can use multiple print statements. In fact you already used two, so you're on the way ...

Ooo, look how i-- fit in there this time. I'm not sure if I like mixing decrementing with printing. How about you?

PS: Just reread and saw that you're shorting out two bits at a time, not one. If that's right, i-- won't quite do it!
[ October 26, 2005: Message edited by: Stan James ]
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15282
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't want to have it "looking all compacted together", then why did you write one long line with "\n" in between?

And System.out.println("\n"); prints two linefeeds.
 
Stephen Foy
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jesper de Jong:
If you don't want to have it "looking all compacted together", then why did you write one long line with "\n" in between?

And System.out.println("\n"); prints two linefeeds.


I suppose that would have been better. ta
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic