clone() overwrite i Java - Hvordan virker det?
Spørgsmål fra min lære: "Override the clone() method in Student. Test your method in TestStudent by creating an object of type Student, printing it out, cloning it, and printing out that clone. If you implemented clone() correctly, the two print outs should print the same values."Hvad jeg har lavet:
Class Student:
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
Class TestStudent:
System.out.println(student1);
Student student7 = (Student) student1.clone();
System.out.println(student7);
Hvorfor smider den en exception på det her?