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 clone class object performs specific cloning operation. first, if class of object not implement interface cloneable, clonenotsupportedexception thrown. note arrays considered implement interface cloneable , return type of clone method of array type t[] t[] t reference 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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -