wood burning stoves 2.0*
The moose likes Java in General and the fly likes indentation help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "indentation help" Watch "indentation help" New topic
Author

indentation help

Mohan Mehra
Ranch Hand

Joined: Jul 28, 2011
Posts: 70
String password = "root123";
args1[5] = oidName;
Connection conn = null;

look at the above lines and tell me is it the correct way of indentation. i.e., including space before and after "=" sign.
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
This might interest you Indentation and Spacing
Riaan Nel
Ranch Hand

Joined: Apr 23, 2009
Posts: 157

That's fine.

Check out this link: Style Guide


"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." - George Bernard Shaw
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3429
    
  12
Mohan Mehra wrote:is it the correct way of indentation* spacing

It is a commonly used way of spacing. The 'correct' way is whatever the style guide you are using says. If you don't have a style guide, then the 'correct' way is whatever style you prefer.

*Indentation is how far the first non-white space character is from the left edge.


Joanne
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7545
    
  18

Mohan Mehra wrote:look at the above lines and tell me is it the correct way of indentation. i.e., including space before and after "=" sign.

What you have looks fine to me.

Other than a few very general rules, such as:
1. Spacing improves readability.
2. Uses spaces for indentation, NOT tabs.
3. Follow basic naming conventions - class names start with a capital letter; most other things (fields, methods and parameters) start with a lowercase letter.
4. Be consistent.
you are probably the best person to decide what is clearest for you.

As for the links you've been given, remember that they are guidelines, NOT rules (even though they're written like rules).
Specifically, there are "rules" in those pages that I don't follow:
  • I always use ALL_CAPS for public constants.
  • I ignore most of section 3, because I simply don't agree with it (especially 3.1, which is utter nonsense).
  • I follow Sun's convention (see below) for matching braces ({}).
  • but that doesn't mean you have to.

    I will say again though - whatever you do decide, be consistent about it.

    The guidelines from Sun itself can be found here.

    Winston

    Isn't it funny how there's always time and money enough to do it WRONG?
    Articles by Winston can be found here
    Roberto Perillo
    Bartender

    Joined: Dec 28, 2007
    Posts: 2258
        
        3

    Winston Gutkowski wrote:The guidelines from Sun itself can be found here.


    This is exactly the code conventions that I use, with the exception that it suggests 80 columns, and I normally use at least 160.


    Cheers, Bob "John Lennon" Perillo
    SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: indentation help
     
    Similar Threads
    what's the syntax for 'tab" in html ?
    Threads trying to get InterruptedException
    Not able to load Class
    UBB code quote
    can anyone tell me how do we update the values in servlet?