IntelliJ IDEA
 
Get IntelliJ IDEA

Encapsulate Fields

Last modified: 11 February 2024

The Encapsulate Fields refactoring lets you hide your data and create the necessary accessors.

Hiding your data and accessing it through an outward interface based on accessor methods is a good idea. Later you can change the data internals, preserving full compatibility with the code relied on the class and its available methods.