clone运用

clone使用实现clone要有两个条件:1. 覆盖clone()方法2. 实现Cloneable接口?例子package testpublic class

clone使用

实现clone要有两个条件:

1. 覆盖clone()方法

2. 实现Cloneable接口

?

例子

package test;public class User implements Cloneable{public int i = 1;@Overrideprotected Object clone() throws CloneNotSupportedException {return super.clone();}}