Prototype mode
Specified kind prototype objects created instance, and create new objects by copying the prototype.
The prototype model is essentially a clone resource, you can build complex objects to solve the problem of consumption
With an already created instance as a prototype to create a prototype of the same or similar new objects by copying this prototype object.
Here, a prototypical instance specifies the kind of object to be created.
Objects created in this way is very efficient , there is no need to know the details of object creation.
1 public class Prototype { 2 public static void main(String[] args) throws CloneNotSupportedException { 3 ProtoTest protoTest = new ProtoTest(); 4 ProtoTest clone = (ProtoTest) protoTest.clone(); 5 clone.getThing(); 6 } 7 } 8 9 class ProtoTest implements Cloneable { 10 private String name; 11 private int age; 12 13 public void getThing () { 14 System.out.println ( "failing summary, it can ask the spring" ); 15 } 16 . 17 public Object clone () throws CloneNotSupportedException { 18 is return (ProtoTest) Super .clone (); . 19 } 20 }