[Illustration Tutorial] One of the ways eclipse has to know: auto-generate getter, setter, and construction methods

Source: Internet
Author: User

Key words: Getters and Setters, getter and setter methods, Constructor using fields, constructor methods (constructors), Eclipse-jee use method, auto-generated code, Eclipse3.5, Schematic usage Tutorials

(1) The Pojo class automatically generates getter and setter methods:

Persion.java The original code:

Right-click in the blanks of the above code, or right-click on the person class name, source–> Generate Getters and Setters, as:

Next, in the Generate Getters and Setters dialog box, select the property ID of the persion and the name hook, or click the "Select All" button directly to check all the properties, and click OK.

Let's look at the code for the Person.java class:

Visible, getter methods and setter methods are automatically generated, more convenient than one to knock code.

(2) automatic generation of construction methods (constructors):

Right-click in the blank of the class code, or right-click on the class name, source–> Generate Constructor using fields, such as:

In the Generate Constructor using Fields dialog box, hook up all or part of the Persion class, and click OK. Such as:

Come down and look at the construction method you generated, see the selected section:

[Illustration Tutorial] One of the ways eclipse has to know: auto-generate getter, setter, and construction methods

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.