``++Cloneable++`` is the marker ``++Interface++`` that indicates that ``++clone()++`` may be called on an object. Overriding ``++clone()++`` without implementing ``++Cloneable++`` can be useful if you want to control how subclasses clone themselves, but otherwise, it's probably a mistake.


== Noncompliant Code Example

----
class Team  {  // Noncompliant
  private Person coach;
  private List<Person> players;
  public void addPlayer(Person p) { ... }
  public Person getCoach() { ... }

  @Override
  public Team clone() { ... }
}
----


== Compliant Solution

----
class Team implements Cloneable {
  private Person coach;
  private List<Person> players;
  public void addPlayer(Person p) { ... }
  public Person getCoach() { ... }

  @Override
  public Team clone() { ... }
}
----


ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
