Why is the Object class's clone() method giving a deep copy of object?
问题 As per the JAVA documentation, the super.clone() when called returns a shallow copy of the object. In the code below I have two objects name and id ; and one primitive variable num . When the super.clone() method is called on the first object, it seems to be creating a deep copy of the objects(name and id) in addition to an expected copy of only num. After cloning the object obj, I have changed its name and id fields. These changes should be reflected in the cloned object if a shallow copy