首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Prototype Pattern 原形模式

2012-10-21 
Prototype Pattern 原型模式1.简介?当创建给力类的实例过程很昂贵或者很复杂时适用?2.实现?JAVA中通过Clon

Prototype Pattern 原型模式

1.简介

?

当创建给力类的实例过程很昂贵或者很复杂时适用

?

2.实现

?

JAVA中通过Cloneable接口和Serializable接口实现

?

3.代码

?

(1)Student.java

?

4.运行结果

?

Original Stduent&Teacher----------------Student.toString : com.siyuan.cloneable.Student@d9f9c3Student.name : studentTeacher.toString : com.siyuan.cloneable.Teacher@9cab16Teacher.name : teacherCloned Stduent&Teacher----------------Student.toString : com.siyuan.cloneable.Student@a62fc3Student.name : studentTeacher.toString : com.siyuan.cloneable.Teacher@89ae9eTeacher.name : teacher

??

热点排行