Input preferences of curly braces (brace) in Eclipse

Source: Internet
Author: User

 

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.