aspose file tools*
The moose likes Beginning Java and the fly likes Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question" Watch "Question" New topic
Author

Question

Stephen Foy
Ranch Hand

Joined: Oct 17, 2005
Posts: 143
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?



Stephen Foy - Microsoft Application Development Consultant
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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 ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14435
    
  23

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Stephen Foy
Ranch Hand

Joined: Oct 17, 2005
Posts: 143
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question