When overriding the clone () function, if the class has a reference field, then deep cloning is necessary.
@Override public Employee clone() throws CloneNotSupportedException{ Employee e = (Employee)super.clone(); e.hireDay = (Date)hireDay.clone(); return e; } In case this is a link to the list:
class Класс { List<Класс2> list; } The override is done:
Класс e = (Класс)super.clone(); for(int i = 0; i<e.list.size(); i++){ e.list.get(i).clone(); } return e; Is it correct?