public class PeopleImpl implements People { // Note the use of "final" to avoid modification // of the name (firstName and lastName). private final String firstName; private final String lastName; private int[] phoneNumber; public PeopleImpl(String firstName, String lastName, int[] phoneNumber) { this.firstName = firstName; this.lastName = lastName; /* * It is necessary to make a copy of the phone number, in order to be * sure that its content will be not changed by the client. */ this.phoneNumber = phoneNumber.clone(); } @Override public final String firstName() { return firstName; } @Override public final String lastName() { return lastName; } @Override public int[] phoneNumber() { /* * Similarly than in the constructor and setPhoneNumber(...), it is * necessary to return a copy of the phone number, in order to be sure * that its content will be not changed by the client. */ return phoneNumber.clone(); } public void setPhoneNumber(int[] newNumber) { phoneNumber = newNumber.clone(); } }