The question I have is pretty noob like so please excuse me for my ignorance as I am a noob.
I came across code some consultants wrote in the company I work for. When I tried delving into the code, I had no idea why a class was implementing some interface called clonable. So I tried to google this clonable mess, and all I see is stuff like "don't use it" or "use copy constructor instead". I don't know what either of those things are. Could someone please elaborate the reasons for when this kind of cloning is actually needed? Why would I clone an object?
I spoke to the ex-consultant and he mentioned this would allow us to chain methods apparently. Like questionSet.dosomething().doAnotherThing().dowth();
public class QuestionSet implements Cloneable {
...
/* (non-Javadoc)
* @see java.lang.Object#clone()
*/
@Override
public QuestionSet clone() {
return new QuestionSet(this);
}
...
}