You can always implement copy constructors in your class:
public Class yourClass
{
public yourClass(yourClass yourClassObject)
{
//implement
}
}
Other than that, you need to read the API about mutable and immutable objects to help you decide how to implement their copy in the constructor.
apines
Practically a Master Poster
633 posts since Apr 2007
Reputation Points: 129
Solved Threads: 55
Objects are always by reference in Java, which means that a=b will point a to the place in the heap the b resides - any future changes to b will affect a as well.
apines
Practically a Master Poster
633 posts since Apr 2007
Reputation Points: 129
Solved Threads: 55
You were talking about objects - in Java objects are always on the heap, never local on the stack, so the scenario you have mentioned cannot happen.
apines
Practically a Master Poster
633 posts since Apr 2007
Reputation Points: 129
Solved Threads: 55
Well, it was not my intention to confuse you - what are you confused about? I'll try to explain it more thoroughly.
apines
Practically a Master Poster
633 posts since Apr 2007
Reputation Points: 129
Solved Threads: 55