深入设计模式-5.原型模式
来源:互联网 发布:ip网络座机怎样使用 编辑:程序博客网 时间:2024/04/29 23:25
1.简介
用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象,原型模式创建对象不需要知道任何创建的细节。在java中由于提供了clone()方法,所以java中的原型模式简单了许多。
2.示例
//原型类
public class Prototype implements Cloneable { private String name; public String getName() { return name; } public void setName(Stringname) { this.name= name; } public Prototype clone()throwsCloneNotSupportedException { return (Prototype)super.clone(); } }//主函数
public class Main { public static void main(String[] args) throws Exception{ // TODO Auto-generated method stub Prototype vo = new Prototype(); for(int i=0;i<10;i++){ vo.clone(); } } }
0 0
- 深入设计模式-5.原型模式
- 设计模式深入学习---Prototype原型模式
- 设计模式:原型模式
- 设计模式------原型模式
- 设计模式 原型模式
- 设计模式-【原型模式】
- 设计模式-原型模式
- 设计模式-原型模式
- 设计模式-原型模式
- 设计模式-原型模式
- 设计模式- 原型模式
- 设计模式:原型模式
- 设计模式 - 原型模式
- 设计模式-原型模式
- 【设计模式】原型模式
- 设计模式-原型模式
- 设计模式-原型模式
- 【设计模式】原型模式
- TextView 设置中划线 下滑线 并消除锯齿
- 如何检测网站后门
- Word Break II
- 使用druid对数据库密码加密
- 挂靠挂靠挂靠挂靠
- 深入设计模式-5.原型模式
- 装饰模式
- Linux进程
- 详解SQL Server 2008数据备份与还原
- Twitter面试题之墙之间的水坑装雨水问题
- 有关打包后的工程文件中mapper.xml无法使用的问题
- oracle进行imp导入数据时报错:ORA-12592: TNS: 包错误
- 【数据结构之链队列的基本运算】
- 8、Preferences