This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes copy constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "copy constructor" Watch "copy constructor" New topic
Author

copy constructor

Pritam Chatterjee
Ranch Hand

Joined: Jul 31, 2011
Posts: 38

how and why to use copy constructors? Example


Pritam
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 44047
    
  33
To create an object identical to the original one.
To prevent the original being altered.Rather than returning the “real” account, you are returning a copy. That allows code to play with the account object without altering the original account object.
Pritam Chatterjee
Ranch Hand

Joined: Jul 31, 2011
Posts: 38

thanks..
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 44047
    
  33
You’re welcome
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: copy constructor
 
jQuery in Action, 3rd edition