The getter () and setter () methods are generated to remove the variable prefix and gettersetter

Source: Internet
Author: User

The getter () and setter () methods are generated to remove the variable prefix and gettersetter

 

 

When the defined variable name has a prefix but does not want to display it in the getter () and setter methods, for example, part of the code of today's project:

1 public class Crime {2 private UUID mId; // ID is the unique element of the Crime identification 3 private String mTitle; // the title is a descriptive name 4 5 public Crime () {6 mId = UUID. randomUUID (); // generate a unique identifier 7} 8 9 public UUID getId () {10 return mId; 11} 12 13 public String getTitle () {14 return mTitle; 15} 16 17 public void setTitle (String mTitle) {18 this. mTitle = mTitle; 19} 20}

In this case, we can File --> Settings --> Code Style --> Java, click Code Generation on the right, and add the prefix (m) to the NamePrefix in the Naming section, as shown in

  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 
Copyright statement: Original Author. for reprinting, please indicate the source.

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.