【发布时间】:2015-03-28 15:40:00
【问题描述】:
public class test implements Cloneable {
@Override
public test clone() {
return (test) super.clone();
}
public static void main(String[] args) {
new test().clone();
}
}
当我尝试编译它时,我得到了error: unreported exception CloneNotSupportedException(在第 4 行,而不是主行)。据我所知,实现Cloneable 的全部目的是摆脱异常。
- 有没有办法使用
super.clone()而不抛出或捕获异常? - 界面实际上有什么作用吗?
【问题讨论】: