Skip to content

about prototype's clone method #707

@yunhenk

Description

@yunhenk

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";
}

}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions