-
-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Closed
Labels
Milestone
Description
Hi, this is the code in the prototype pattern.And I wonder why this clone() method creates a new object rather than clone itself? Thanks.
public class OrcBeast extends Beast {
public OrcBeast() {}
@OverRide
public Beast clone() throws CloneNotSupportedException {
return new OrcBeast();
}
@OverRide
public String toString() {
return "Orcish wolf";
}
}