Your First Cup: An Introduction to the Java EE Platform

ProcedureGenerating the Accessor Methods for the Properties

Use the NetBeans 6.7 IDE Encapsulate Fields wizard to create getters and setters for the properties.

  1. Right-click in the editor window.

  2. Select Refactor->Encapsulate Fields from the popup window.

  3. In the Encapsulate Fields dialog, select the Create Getter and Create Setter checkboxes for age, yourBD, ageDiff, and absAgeDiff.

  4. Click Refactor.

    You should now see two methods for each property, one to set the value and one to get the value of the variable for that property.