1.Concept
Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype. - Gof
2.QA
Clone 淺拷貝,複製值類型,不復制引用類型;引用indicate the same object.==
Copy 深拷貝,值類型與引用類型都做複製; Use the Serialization to deep copy the Object.
原型模式創造出的對象拷貝與原有對象存在以下關係。
1、原對象 != 新對象拷貝
2、原對象.equals(新對象拷貝) = true(前提是添加了適當的equals方法)
3、原對象.getClass().equals(新對象拷貝.getClass())
3.Good example.
DOTA, 劍聖,孫悟空。