为什么我有错误,但没有异常?
Why I have an error, but not an exception?
Invoking Object's clone method on an instance that does not implement
the Cloneable interface results in the exception
CloneNotSupportedException being thrown.
为什么我有错误
clone() has protected access in java.lang.Object
但不是 CloneNotSupportedException 异常?
public class Test
{
public static void main(String[] args)
{
Test2 c1 = new Test2();
Test2 c2 = (Test2) c1.clone(); // error: clone() has protected access in java.lang.Object
}
}
class Test2
{
}
因为编译时出错
运行时出现异常。该程序甚至没有编译,所以你没有达到运行时。
Invoking Object's clone method on an instance that does not implement the Cloneable interface results in the exception CloneNotSupportedException being thrown.
为什么我有错误
clone() has protected access in java.lang.Object
但不是 CloneNotSupportedException 异常?
public class Test
{
public static void main(String[] args)
{
Test2 c1 = new Test2();
Test2 c2 = (Test2) c1.clone(); // error: clone() has protected access in java.lang.Object
}
}
class Test2
{
}
因为编译时出错
运行时出现异常。该程序甚至没有编译,所以你没有达到运行时。