62,623
社区成员
发帖
与我相关
我的任务
分享
package zhao;
public class TestClone implements Cloneable {
/**
* @param args
*/
public static void main(String[] args) {
TestClone t = new TestClone();
TestClone t1 = (TestClone)t.clone();
}
public Object clone() {
Object o = null;
try {
o = super.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
return o;
}
}
package zhao;
public class testClone implements Cloneable {
/**
* @param args
*/
public static void main(String[] args) {
StringBuffer sb = new StringBuffer();
StringBuffer buffer2 = (StringBuffer)sb.clone(); // 因为clone()方法是protected类型的,所以不能在另一个类中使用StringBuffer的clone方法,没发实现
}
}
package zhao;
public class TestClone implements Cloneable {
/**
* @param args
*/
public static void main(String[] args) {
TestClone t = new TestClone();
TestClone t1 = (TestClone)t.clone();
}
public Object clone() {
Object o = null;
try {
o = super.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
return o;
}
}