本帖最后由 郭强 于 2013-4-13 14:22 编辑
public class Clonetest
{
public static void main (String[] args)
{
try{
Emloyee original = new employee("Tom",1000);
Employee copy = original.clone();
..........(以下省略)
}
........
}
}
class Employee implements Cloneable
{
........(省略)
public Employee clone() throw CloneNotSupportedException
{
Employee cloned = (Employee)super.clone();//疑问就在这儿
return cloned
}
.....
}
调用cloned方法时中的super是指的那个Cloneable接口吧?调用它的cloned方法,但是它的cloned方法不是虚拟的吗?怎么调用啊?调用后返回的为什么就是Emloyee类型啊?
|
|