Eclipse Sets the format of the code curly braces
There are many styles of writing code, common in three styles:
1, K & R style: This style of code is relatively compact, the advantage is in textbooks or printed into paper when compared to the provincial place; The disadvantage is the brace matching problem, the code is large, it is not good to find the last parenthesis position, can only be marked by post-comment
Public class Test { publicstaticvoid main (String args[]) }}
2, the standard style (BSD style): This style of display code is relatively loose, the advantages are hierarchical, written code is easy to read, the disadvantage is: waste space, especially when printing code
Public class test{ publicstaticvoid main (String args[]) { }}
3, GNU style: This style originated from GNU, all GNU Software Foundation adopted this style, the advantages and disadvantages of the same as the BSD style, characterized by parentheses before and after the empty two lattice.
Public class Test { publicstaticvoid main (String args[]) { } }
I personally prefer the standard BSD style, because the code is clearly structured, concise and easy to read, and Eclipse can customize the code style by setting the following method:
1, open eclipse,window menu, preferences option;
2. Find the Java-->code style-->formatter (java--> code style--format) setting, New one format. The default format of Eclipse is not allowed even if you edit the change.
3, so we want to create a new format of our own. As you can see from the previous figure, I've got the name Mybracesoption (because I changed the format of the curly braces, so I got the name). Here for demonstration, I re-created a new format, re-named MyEclipse;
4, braces is to change the format of curly braces, the following heap drop-down menu is the code in different locations of the curly brace format, you can try it yourself. If you and I like the standard style, then recommend you in addition to the penultimate array initializer: Same line, the rest of the choice: Next line. After that, always OK, the setup is complete. You can see that the format has changed when you edit the code.
Eclipse code format: "{}" format setting