Results 1 to 3 of 3
  1. #1
    Reeling is offline Member
    Join Date
    Jan 2012
    Posts
    49
    Rep Power
    0

    Default Formatting inquiries

    Hello, I have been programming in a couple different languages for about 6 months now. I like to keep everything looking good, and make sure I follow the naming conventions and indenting conventions for each language. So naturally I went to the Oracle website and read through the guide about it all and I just have some questions about it. Specifically about where to put the opening parenthesis.

    According to Oracle you should start your methods and statements and all these things like this:
    Java Code:
    if(true){
        stuff here
    }
    I find this to be hard to follow when the code starts stacking up, and I really prefer to write it like this:
    Java Code:
    if(true)
    {
        stuff here
    }
    Is it okay that I do this, or should I just bite my tongue and do it the way Oracle says to do it.

    Following the same train of thought, they also say to do if statements in a really confusing way, at least to my eyes.
    Java Code:
    if(true){
        do stuff
    }else{
        do stuff
    }
    I prefer to write it in the same way as before, with each statement on its own separate line and each parenthesis on its own separate line. Is that okay?

    Java Code:
    if(true)
    {
        stuff
    }
    else
    {
        stuff
    }
    One final question, tabs or spaces?

    All feedback is appreciated. Thanks.
    Last edited by Reeling; 10-18-2012 at 02:11 AM.

  2. #2
    Abizzar is offline Member
    Join Date
    Oct 2012
    Location
    Georgia
    Posts
    7
    Rep Power
    0

    Default Re: Formatting inquiries

    I mean it honestly is just the coders preference I use tabs and spaces sometimes if it becomes misaligned. Also I prefer to write my code like this:
    Java Code:
    if(true)
    {
           ffff
    }
    It just makes it look cleaner and organized in my opinion but doing it the other way probably saves more time.

  3. #3
    joshdgreen's Avatar
    joshdgreen is offline Senior Member
    Join Date
    Oct 2010
    Location
    Colorado Springs, CO
    Posts
    212
    Rep Power
    5

    Default Re: Formatting inquiries

    I write my code the same way, except in cases of if statements with one line of code, for example:

    Java Code:
    if(true)
       stuff
    else
       stuff2
    or even:

    Java Code:
    if(true) stuff;
    else stuff2;
    Sincerely, Joshua Green
    Please REP if I help :)

Similar Threads

  1. Formatting Output
    By Rahim2312 in forum New To Java
    Replies: 18
    Last Post: 05-04-2012, 09:45 AM
  2. Help with formatting output
    By John Lord in forum New To Java
    Replies: 1
    Last Post: 10-31-2010, 12:10 PM
  3. Formatting jTexfields
    By JavaTrouble in forum New To Java
    Replies: 33
    Last Post: 05-28-2010, 12:46 PM
  4. Number formatting
    By gandalf5166 in forum New To Java
    Replies: 7
    Last Post: 03-26-2010, 02:54 AM
  5. formatting..
    By sireesha in forum New To Java
    Replies: 16
    Last Post: 06-26-2009, 07:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •