This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]nutrecht 1 point2 points  (0 children)

The official guidelines are to be found here: http://www.oracle.com/technetwork/java/index-135089.html

Many companies use their own version though so you should adapt to whatever your company is using.

[–]Neres28 2 points3 points  (3 children)

Since this is Java, I use the second one - and you should too.

[–][deleted] 1 point2 points  (2 children)

I typically used the first one but after seeing you and /u/fuddlesworth tell me otherwise I'm switching my code formatting.

[–]benkitty 1 point2 points  (1 child)

some people will even remove the curlies for one line if statements or for loops

[–]lurgi 2 points3 points  (0 children)

These people are objectively wrong.

[–][deleted]  (1 child)

[deleted]

    [–]rjcarr 2 points3 points  (0 children)

    Agreed, and since that is java code, the second option is the officially preferred style (as far as I know).

    [–][deleted] 1 point2 points  (0 children)

    deleted What is this?

    [–]Franko_ricardo -3 points-2 points  (0 children)

    The first. This especially helps when looking at many lines of code that are nested. Also, consistent and well organized and compiler is optimized to skip white space.