Easy Solution to implement clone java object
来源:互联网 发布:yum安装软件原理 编辑:程序博客网 时间:2024/05/16 05:21
The easiest solution to this is to make the base class "implements Cloneable" and have the base class and all sub-classes contain the clone() method. When a class has data in it that must be cloned, adding a line or two to the clone() method is straightforward.
Example:
abstract public class X implements Cloneable { public X clone() throws CloneNotSupportedException { return (X) super.clone(); }} abstract public class Y extends X { public Y clone() throws CloneNotSupportedException { return (Y) super.clone(); }} public class Z extends Y { public Z clone() throws CloneNotSupportedException { return (Z) super.clone(); }} public class test1 { public void function() throws CloneNotSupportedException { Y varY1 = new Z(); Y varY2 = varY1.clone(); }}
From:http://en.wikipedia.org/wiki/Clone_(Java_method)
- Easy Solution to implement clone java object
- java.lang.Object.clone()
- java object之clone
- Java Object Clone
- LeetCode-Easy-Java-Implement strStr()
- java studyd 003 --object clone
- java.lang.Object.clone()分析
- java.lang.Object.clone()分析
- java.lang.Object.clone()分析
- Java.lang.Object.clone()分析
- java.lang.Object.clone()分析
- Java Object的clone方法
- java.lang.Object.clone()分析
- java.lang.Object.clone()分析
- java.lang.Object.clone()解读
- How to clone an object in JavaScript
- Java 关于java.lang.Object.clone()
- [LeetCode] Clone Graph, Solution
- SQL当修改表的时候,必须重新编译与之相关联的视图。
- Asp.Net4.0/VS2010新变化(3):webform中也可以直接url路由2
- iOS动画效果和实现
- 分步学习Struts(一)框架
- java shell排序
- Easy Solution to implement clone java object
- MyEclipse内存溢出解决方法
- html学习笔记-基础概念
- UVa 10651 - Pebble Solitaire 状态压缩 dp
- 超乎想象的using(C#)
- 2013年蓝桥杯模拟赛答案
- 和菜鸟一起学OK6410之tftp下载内核,nfs挂载文件系统全过程详解
- QT 小技巧
- ZOJ 2760 How Many Shortest Path(floyd+最大流)