Eclipse sets prefix for member variables and eclipse prefix

Source: Internet
Author: User

Eclipse sets prefix for member variables and eclipse prefix

Eclipse can automatically generate getter, setter, and constructor.

Menu-Source,

Generate Getters and Setter, Generate Constructor using Fields,

You only need to check and click OK to generate the corresponding code. You can also add comments.

However, the Java member variables generally start with m, such as mText. In this way, the generated getter and setter become

Public String getmText () {return mText;} public void setmText (String mText) {this. mText = mText ;}

Code cleaner will definitely Delete unnecessary 'M' one by one.

In fact, Eclipse can set a prefix for member variables.

Open Preferences and enter prefix in the search box.

Select Java-Code Style

Edit Fields, Prefix list: Enter 'M '.

Click OK to automatically ignore the prefix of the generated code.


In visual C ++, is it necessary to specify the prefix before the variable name of a class member?

This is not necessary and is rarely seen in console applications.
In MFC, you will find a lot of such problems, mainly for understanding. You will know what this variable represents and what type it is.

How can I find a variable in eclipse and change it in a unified manner?

Crtl + f
Select the variable and press enter after the shifr + alt + R changes.
 

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.