It's the same object!
No, it isn't. It just results in the same output when you use it with your LOG.debug
method. If LOG.debug
is using toString
, that means it has the same string result from toString
. This could be because of your implementation of toString
, or it could be because the object has the same hash code, since the standard Object#toString
outputs the class name, @
, and then the hash code in hex. See Object#toString
in the Javadoc for details, but basically:
The toStringmethod for class
Objectreturns a string consisting of the name of the class of which the object is an instance, the at-sign character
@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Re your title:
Can implementing Java copy constructor result in same instance?
No, not in Java.