I have a class (Literal). I need to be able to keep an intact Literal instance in memory throughout my application, and have a copy of it which I can alter. I have used two ways to do this:
- class
Literal
implementsCloneable
and overrideObject.clone()
method. Factory constructor:
public Literal(Literal lit){ this = lit; }
In both cases copying doesn't work. Every change I make to the copy, changes the original. Does anybody have any idea what I'm doing wrong?