The getter that broke encapsulation
java
class Team {
private List<String> members = new ArrayList<>();
public List<String> getMembers() { return members; }
}
The field is private and access is through a getter. Is encapsulation intact?
java
class Team {
private List<String> members = new ArrayList<>();
public List<String> getMembers() { return members; }
}
The field is private and access is through a getter. Is encapsulation intact?