Encapsulation means bundling data and the methods that operate on it inside one unit (a class) and hiding the internal state behind a controlled public interface. Callers interact through methods, not by poking at raw fields.
Why hide state
If anyone can change a field directly, you can never guarantee the object stays valid. Encapsulation lets the class enforce its own invariants.
{
balance;
{
(amount <= )
();
(amount > balance)
();
balance -= amount;
}
{ balance; }
}
