One common design pattern in Java programs is to make fields accessible and changeable only by methods in the defining class. In the convention used by JavaBeans components, the field is given private access and accessor methods are written for the field with broader access privileges. The names of the accessor methods are created by prefixing get and set to the field's name. If you have fields that are visible to other classes and would like to better control access to those fields, you can use the IDE's Encapsulate Fields command to automate the necessary code modifications. The Encapsulate Fields command does the following things:
To encapsulate fields in a class:
|