What type of copy does the default java.lang.Object.clone() method perform -
i new java can 1 tell me please.
shallow copy: primitive types , references copied
deep copy: objects copied recursively
there no default implementation clone()
you can @ documentation clone():
the method
cloneclassobjectperforms specific cloning operation. first, if class of object not implement interfacecloneable,clonenotsupportedexceptionthrown. note arrays considered implement interfacecloneable, return type of clone method of array typet[]t[]treference or primitive type. otherwise, method creates new instance of class of object , initializes fields contents of corresponding fields of object, if assignment; contents of fields not cloned. thus, method performs "shallow copy" of object, not "deep copy" operation.
Comments
Post a Comment