Set your own Eclipse code style (internal) and eclipse code
After several code submissions, we found that many people's code styles are not standardized. I personally think it is necessary to set the code specifications.
In general, there are three code styles, two of which are similar to the following:
public void function(){ //function body}
Obviously, the Code becomes hard to read when multiple layers of code blocks are nested.
The programmer should remember that the code is written to others, and it is absolutely necessary to avoid writing only (write-only) the code. A good code style will inevitably take advantage of two points: indent and appropriate line breaks.
My code style is as follows:
public void function(){ //function body}
Note that brace pair must be aligned for the following reasons:
public void function1(){ for(int i = 0; i < 10; i ++){ for(int j = 0; j < 10; j ++){ //some code } }}
public void function2(){ for(int i = 0; i < 10; i++) { for(int j = 0; j < 10; j++) { //some code } }}
Which one do you mean is easy to see and which one looks more comfortable?
Okay: I am not talking much about it. Next I will explain how to set my own code style in Eclipse:
Step one: Window> Preferences on the menu
Step two: Enter the code in the search box
Step three: Select Java-> Formatter and click New... Button (below Eclipse [built-in)
Step four: enter your favorite name in Profile name. Here, MyJavaStyle is used as an example:
Step five: On the Indentation tab, select Statements within 'Switch 'body"
Step six: On the Braces tab, except for Anonymous class declaration, select Next Line
Step seven: On the Control Statements tab, select:
Step eight: Apply-> OK-OK ......