#171 Code Review of a Client Model
Perform a code review:
public final class Client {
public long id;
public String name;
public static ArrayList<String> roles = new ArrayList<>();
private Client(long id) {
this.id = id;
}
public String getName() {
return name;
}
public synchronized void setName(String name) {
this.name = name;
}
@Override
public boolean equals(Object o) {
Client client = (Client) o;
return id == client.id && name == client.name;
}
@Override
public int hashCode() {
return name.hashCode();
}
}Question review
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor