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