求解,小白问个问题,在这个例子里super和this为什么是同一个类了
下面从书上截了一段下来,没看懂为什么super和this都是指代的Employee,,
public class CloneTest
{
public static void main(String[] args)
{
try
{
Employee original = new Employee("Tom", 100);
}
catch (CloneNotSupportedException e)
{
e.printStackTrace();
}
}
}
public class Employee implements Cloneable
{
private String name;
private double salary;
private Date hireDay;
public Employee(String n, double s)
{
name = n;
salary = s;
hireDay = new Date();
}
public Employee clone() throws CloneNotSupportedException
{
System.out.println(super.getClass().getName());-----这里输出为Employee
System.out.println(this.getClass().getName());-----这里输出也为Employee
Employee cloned = (Employee) super.clone();
return cloned;
}