This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
so this is what your Library class looks like?
and you want to clone that object, and every attribute should be cloned also ?
JDBCSupport - An easy to use, light-weight JDBC framework -
Joined: Dec 03, 2006
My code is like this
and I want to copy whole structure without id attribute from all objects.
I hope this makes my question more clear.
Joined: Feb 23, 2009
make your Librar Cloneable by implementing the Cloneable marker interface ..
override the Object's clone method and change the access modifier to public ..
in that method call super.clone();
now it depends on whether or not you want a shallow or deep clone ..
shallow clone uses the same instance of your instance variables and assigns it to the cloned Library object.
Deep Clone also clones your instance variables by invoking their clone method. Hence also these have to be Cloneable.