创建型模式---原型模式
来源:互联网 发布:知我者,二三子 编辑:程序博客网 时间:2024/05/02 02:51
一、优缺点
原型模式的优点在于:创建对象的时候没有用new方式,而是直接是对内存二进制流的拷贝,相对于new方式,性能更优,
原型模式的缺点在于:直接对内存二进制流的拷贝少了约束。
二、实现
public class YuanXingMode {/** * 原型模式的优点在于:创建对象的时候没有用new方式,而是直接是对内存二进制流的拷贝,相对于new方式,性能更优, * 原型模式的缺点在于:直接对内存二进制流的拷贝少了约束。 */public static void main(String[] args) {Prototype p = new Prototype("a");Prototype pp = (Prototype) p.clone();System.out.println(p.name);System.out.println(pp.name);}}class Prototype implements Cloneable {String name;public Prototype(String name) {this.name = name;}@Overridepublic Object clone() {try {return super.clone();} catch (CloneNotSupportedException e) {e.printStackTrace();return null;}}}
- 创建型模式-原型模式
- 创建型模式---原型模式
- 创建型模式--原型模式
- 创建型模式-原型模式
- 原型模式(创建型模式)
- 创建型模式-原型
- 创建型--原型模式
- 原型模式(创建型)
- 【设计模式】创建型模式-原型模式
- 设计模式 - 创建型模式 - 原型模式
- 设计模式->创建型模式->原型模式
- 创建模式->原型模式
- Prototype原型(创建型模式)
- Prototype原型(创建型模式)
- 【创建型模式】protopyte(原型)
- 原型模式(创建型)
- 创建型之原型模式
- 创建型-原型模式(prototype)
- $.getJSON()跨域请求
- CString转char * ,string
- jQuery选择器之过滤选择器之表单对象属性过滤选择器
- 1.5
- MFC对话框置顶SetWindowPos()用法
- 创建型模式---原型模式
- HDU 2007 平方和与立方和 (新的交换)
- 住房公积金“大数据”
- sizeof ()那点事
- NYOJ125---盗梦空间
- pinyin4j使用
- http://poj.grids.cn/practice/2746--约瑟夫问题
- EOS条件查询
- string,wstring,cout,wcout 与中文字符的输入输出 .