Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Java : Questions on clone method
- `@override
- public MyClass clone(){
- Myclass clonedObj = super.clone(); // This is why the classtree all needs to be cloneable
- // now copy values of all members to the new obj.
- // be carefull to not copy references
- clonedobj.setMyMember(this.getMyMember()); // copy of member var;
- clonedobj.setMyotherMember(this.getMyOtherMember().clone()); // a composit obj must be cloned.
- }
- `
Add Comment
Please, Sign In to add comment