I recently watched some videos about Java by Dr. Zhang LongZhong. I found that every time I write some methods, the curly braces are different from mine, I thought it was manually modified by the Teacher. This helps us to get used to reading. Later, more and more people saw that the change was automatically generated by Eclipse IDE. I was wondering, I searched the internet and had a thought, but it was not very detailed. I hope my younger brother can help you in this blog post. Thank you for your support.
I. Brackets generated by the original Eclipse
Public ClassTest {
Public Static VoidMain (String [] args ){
System.Out. Println ("input preferences of brace in Eclipse ");
System.Out. Println ("this is the curly braces generated by the original Eclipse ");
}
}
Ii. Modified curly braces
Public ClassTest1
{
Public Static VoidMain (String [] args)
{
System.Out. Println ("input preferences of brace in Eclipse ");
System.Out. Println ("modified curly braces ");
}
}
Is it in line with our coding habits?
3. How to modify it?
The idea provided on the network is Windows> Preferences> Java> Code Style> Formatter.
After my attempt, you can configure the usage to achieve the goal. The method is described as follows.
Based on the Search Ideas, find Windows> Preferences> Java> Code Style> Formatter (there should be nothing to say)
No Edit. Click it.
We can see a label Braces, which is the configuration option of curly Braces. If you do not understand the meaning of each label, you can use some tools to translate it, or the most stupid way is to try it one by one to know its purpose.
However, after you modify one, Eclipse will report a warning.
The general meaning is that built-in is a built-in file. We can create a new one (and rename it)
Well, I will create a New one, first return to the original interface (the first graph) with a New one, click
Make sure to select the profile. The configuration will be opened after OK. At this time, select the Braces label and modify the options (generally choose Next line) we recommend that you select Next line, Apply-> OK, except for the last one that is not modified.
Control statements: Set to general. if else, select only keep else if on one line.
Now let's take a look at the modified results (similar to the curly braces generated after the above two changes)
(To http://www.blogjava.net/lishunli/archive/2010/01/07/308603.html)