class Employee implements Cloneable
{ public Employee clone() throws CloneNotSupportedException
{ return (Employee)this.clone();
}
public static void main (String[] args) {
Employee ee=new Employee();
try{System.out.println (ee.clone());
}catch(Exception e){
}
}
}
return (Employee)this.clone(); 这个是什么意思?
2012-01-22 14:36
提问者采纳
这是Object对象的clone克隆/复制方法作用是执行后将复制一份当前对象,并返回。 使用clone方法的类必须先实现Cloneable接口,不然clone方法会直接返回CloneNotSupportedException不支持克隆的异常 所以 Employee必须 implements Cloneable 又由于clone方法是Object就具有的,所以可以直接返回return (Employee)this.clone();
评论(10)
47
3
2015-5-5 17:51
jenercy
jenercy
2013-9-12 16:22
徐亮头
徐亮头
2013-3-18 09:45
weimu2002
weimu2002
2012-12-26 16:13
热情的能量
热情的能量
2012-9-11 11:26
sjybdzd
sjybdzd
class Employee implements Cloneable
{ public Employee clone() throws CloneNotSupportedException
{ return (Employee)this.clone();
}
public static void main (String[] args) {
Employee ee=new Employee();
try{System.out.println (ee.clone());
}catch(Exception e){
}
}
}
return (Employee)this.clone(); 这个是什么意思?
2012-01-22 14:36
提问者采纳
这是Object对象的clone克隆/复制方法作用是执行后将复制一份当前对象,并返回。 使用clone方法的类必须先实现Cloneable接口,不然clone方法会直接返回CloneNotSupportedException不支持克隆的异常 所以 Employee必须 implements Cloneable 又由于clone方法是Object就具有的,所以可以直接返回return (Employee)this.clone();
评论(10)
47
3
345






