当前位置: 首页 > wzjs >正文

建设银行鄂州分行官方网站优质的seo网站排名优化软件

建设银行鄂州分行官方网站,优质的seo网站排名优化软件,wordpress 原子特效,wordpress会员中心添加头像上传文章目录 一、原型模式定义二、例子2.1 利用Cloneable克隆接口实现的。2.1.1 定义可复制自身的User类2.1.2 定义原型工厂PrototypeFactory2.1.3 使用 2.2 JDK源码——ArrayList 三、其他设计模式 一、原型模式定义 类型: 创建型模式 目的: 用于创建重复…

文章目录

  • 一、原型模式定义
  • 二、例子
    • 2.1 利用Cloneable克隆接口实现的。
      • 2.1.1 定义可复制自身的User类
      • 2.1.2 定义原型工厂PrototypeFactory
      • 2.1.3 使用
    • 2.2 JDK源码——ArrayList
  • 三、其他设计模式

一、原型模式定义

类型: 创建型模式
目的: 用于创建重复的对象,同时又能保证性能。

二、例子

2.1 利用Cloneable克隆接口实现的。

2.1.1 定义可复制自身的User类

public class User implements Cloneable {protected String id;protected String name;public User(String id, String name) {this.id = id;this.name = name;}public Object clone() {Object clone = null;try {clone = super.clone();} catch (CloneNotSupportedException e) {e.printStackTrace();}return clone;}
}

2.1.2 定义原型工厂PrototypeFactory

public class PrototypeFactory{private static User prototypeUser;public static User setPrototypeUser(User prototypeUser){prototypeUser = prototypeUser;}public static User getPrototypeUser(){if(prototypeUser == null){prototypeUser = new User("0","xxxx");}return (User) prototypeUser.clone();}
}

2.1.3 使用

public static void main(String[] args) throws Exception{PrototypeFactory.setPrototypeUser(new User("root","admin"));User prototypeUser1 =  PrototypeFactory.getPrototypeUser();User prototypeUser2 =  PrototypeFactory.getPrototypeUser();User prototypeUser3 =  PrototypeFactory.getPrototypeUser();
}

除了clone,还可以使用反序列化和拷贝工具实现原型模式。

2.2 JDK源码——ArrayList

public class ArrayList<E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, java.io.Serializable{public Object clone() {try {ArrayList<?> v = (ArrayList<?>) super.clone();v.elementData = Arrays.copyOf(elementData, size);v.modCount = 0;return v;} catch (CloneNotSupportedException e) {// this shouldn't happen, since we are Cloneablethrow new InternalError(e);}}
}

三、其他设计模式

创建型模式
结构型模式

  • 1、设计模式——装饰器模式(Decorator Pattern)+ Spring相关源码

行为型模式

  • 1、设计模式——访问者模式(Visitor Pattern)+ Spring相关源码
  • 2、设计模式——中介者模式(Mediator Pattern)+ JDK相关源码
  • 3、设计模式——策略模式(Strategy Pattern)+ Spring相关源码
  • 4、设计模式——状态模式(State Pattern)
  • 5、设计模式——命令模式(Command Pattern)+ Spring相关源码
  • 6、设计模式——观察者模式(Observer Pattern)+ Spring相关源码
  • 7、设计模式——备忘录模式(Memento Pattern)
  • 8、设计模式——模板方法模式(Template Pattern)+ Spring相关源码
  • 9、设计模式——迭代器模式(Iterator Pattern)+ Spring相关源码
  • 10、设计模式——责任链模式(Chain of Responsibility Pattern)+ Spring相关源码
  • 11、设计模式——解释器模式(Interpreter Pattern)+ Spring相关源码
http://www.dtcms.com/wzjs/152759.html

相关文章:

  • 怎样做可以互动留言的网站whois查询 站长工具
  • 东莞网站建设属于什么专业产品运营方案
  • wordpress 自动登陆上海专业seo公司
  • 网站搭建类型app推广联盟平台
  • 网站建设浅析樱花bt引擎
  • 江苏城乡建设厅官方网站北京计算机培训机构哪个最好
  • 网站子目录是什么意思seo职位要求
  • 专业版装修用什么网站做导航条企业网站制作
  • 厦门app网站建设磁力链bt磁力天堂
  • 宁海有做网站的吗推广渠道有哪些
  • 源码怎样做网站免费个人网页制作
  • 网站图片上怎么做弹幕效果大型网站建设公司
  • 自己做项目的网站网址链接生成器
  • 北京做微信网站哪家好北京网站seo招聘
  • 营销企业网站建设北京搜索引擎优化管理专员
  • 怎样做网站系统网上推广平台有哪些
  • 手机网站需要多少钱可以发广告的100个网站
  • 铭万做的网站如何设计企业网站
  • 兰州做网站多少钱关键词怎么做快速的有排名
  • 品牌网站搭建网络推广计划书
  • wordpress仿qq空间模板长沙网站优化培训
  • 如何做魔道祖师网站如何免费创建自己的平台
  • 如何做打码网站张家界seo
  • 世界杯网站建设百度如何精准搜索
  • 天津网站建设外包百度指数关键词工具
  • 一台云服务器多少钱衡阳seo
  • 江门网站建设报价网站关键词排名优化价格
  • 安贞做网站公司今日油价最新
  • 免费个人博客网站模板下载制作网站的网址
  • wordpress 下载模板站网站seo运营培训机构