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

宠物网站建设报告/搜索引擎优化的定义

宠物网站建设报告,搜索引擎优化的定义,东莞网站建设中企动力技术支持,做电影类网站收入怎么样文章目录 一、原型模式定义二、例子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.whsansanxincailiao.cn/news/30288990.html

相关文章:

  • 广州市增城区建设局网站是什么/百度快照收录
  • 广州微网站建设/做网站用什么编程软件
  • 专业建站公司建站系统/百度首页排名怎么做到
  • 如何选择建设网站类型/爱站网关键词搜索工具
  • 无货源电商怎么找货源/关键词seo报价
  • 百度网站介绍显示图片/重庆森林经典台词梁朝伟
  • wordpress建立手机网站/百度一下首页百度一下
  • 手机网站加速器/百度搜索风云榜明星
  • 为什么要建设营销型网站/品牌运营策划方案
  • 破解织梦做的网站/百度搜索风云榜排名
  • wordpress搬家后变慢/网站关键词优化报价
  • 做游戏赚钱的网站/音乐接单推广app平台
  • 网站建设系统平台/百度网址是什么
  • 计算机系毕设代做网站/关键词挖掘站长工具
  • 国外服务器ip大全/seo自学教程
  • 商城网站建设资讯/网站如何建立
  • 微信导航网站模板/重庆人力资源和社会保障网官网
  • 个人网站怎么做的模板/百度一下app下载安装
  • 基于jsp的网站建设论文/集客营销软件
  • 开个人网站如何赚钱/郑州网络推广代理顾问
  • 柳州网站建设公司/网络营销的重要性与意义
  • 上海地区做旧物回收的网站/最新新闻头条
  • 二级域名查询ip/新乡seo网络推广费用
  • 游戏ui设计最好的培训机构/百度刷排名优化软件
  • 建网站空间可以不买/网络运营是什么专业
  • 余姚有专业做网站的吗/新乡网站推广
  • 上海网站优化公司/seo导航站
  • 网站备案连接怎么做/优化设计四年级上册数学答案
  • 买了域名以后如何做网站/小红书关键词排名怎么做
  • 北京移动网站建设公司排名/广告资源对接平台