• 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

Formatting - Spacing

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone tell me the proper spacing rules.
In the assignment tutorial, I see:
System.out.println( "Spot is now home" );
}
***Notice the space after the println method parentheses and the string
In the style guide, I see:
System.out.println("Oatmeal is good and good for you");
***notice the no spacing between the parentheses and the string. Which is correct, or does it even matter?
This is my understanding of the spacing rule:
1 - all identifiers are surrounded with whitespace unless it reduced clarity
2 -note the exceptions in the style guide (methods, arrays, pre and post increment, and casting)
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm whispering so only you will hear this...
There would appear to be a couple of inconsistencies regarding the style guide and what is actually expected. Mostly to do with some spacings not addressed in the style guide.
A rule that should get you by: If you were to surround all of your String literals with spaces, you would not be in error.
 
It sure was nice of your sister to lend us her car. Let's show our appreciation by sharing this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic