(Conversion) Java object cloning (Clone), Cloneable interface, Serializable interface in-depth discussion, phpclone object cloning
Address: http://blog.csdn.net/kenthong/article/details/5758884
Part I
Let's just start Part II.
Part II
When talking
Directory
PrerequisitesWhy clone?Object clone and whyHow to cloneClone attitudeOther optionsComparison with serializablePerformance
Prerequisites
To Understand Java clone, you must first review the following knowledge.Java is classified into two
Suddenly saw the object cloning this thing, and looked at it is the object class in the native method, feeling can improve the operation efficiency of the program. To study this thing.Part I. Briefly describe the cloning of an objectUsually when we
Tips"Effective Java, third Edition" an English version has been published, the second edition of this book presumably many people have read, known as one of the four major Java books, but the second edition of 2009 published, to now nearly 8 years,
Objective
Java Cloning (clone) is one of the features of the Java language, but it is rarely used in practice. But sometimes cloning can be more convenient and more efficient.
For clones (clone), Java has some limitations:
1. The cloned class
Creation of objects in JavaClone is copied as its name implies, and in the Java language, the Clone method is called by the object, so the object is copied. The so-called Replication object, the first to allocate a source object and the same size of
First, describeThe prototype pattern is a prototype object that identifies the type of object to be created, and then copies the creation of more homogeneous objects using the method of copying the prototype object. For example, we have an object in
The Clone method returns a copy of the instance object, typically X.clone ()! = X | | X.clone (). GetClass () = = X.getclass () | | X.clone (). Equals (x) is also true, but is not strictly required, and we can override this method by overriding
Although cloning methods are defined in the most basic object of all classes, clones are not automatically performed in each class. This may seem strange, because the underlying class method is certainly available in derivative classes. But Java
Read Catalogue
Why do you want to clone?How to implement cloningShallow clones and deep clonesSolving multi-layer cloning problemsSummarize
Say you want to copy a simple variable. Very simple:int apples = 5; int pears = apples; More
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.