First, the construction method
1. Default Construction method
Second, method overloading (the way)
1, the use of the Order of parameters
2. Data types Using Parameters
3, the use of the number of parameters
4. Use different return types (method type)
Third, the keyword this
1. Call the constructor method in the constructor method
- The call action of the constructor must be placed at the very beginning Constructor the must is the first statement in a Constructor
- So only one other constructor can be called inside each constructor
Iv. cleanup: End and garbage collection
V. Member initialization
Vi. Summary
This chapter is mainly about initialization and garbage cleanup, this book is the description of the initialization is a relatively basic knowledge, relatively familiar with, and garbage cleanup is automatically executed by the "garbage collector", relatively unfamiliar.
The "garbage collector" does bring great convenience to the programmers, and the functionality is quite powerful. It operates in a variety of ways, such as: reference counting (reference counting, a simple, slow GC technique; counting, which is the number of times the object is referenced, and the memory it consumes when the counter is 0 o'clock). However, in order to speed up, its true principle is based on "live on stack (stack) or static storage (static storage space)" On the reference and tracked to the object, is still the object, not found the object will naturally become garbage, this way, The JVM uses a "self-reflection (adaptive)" garbage collection mechanism. As for how to deal with surviving objects, there are "copy collectors", "Mark and Sweep", "stop-and-copy" and so on. Different JDK versions will have different garbage collection mechanisms, but this book is written for Java 2, now Java 8 may have a faster, better, more secure "garbage collector" (in the future to continue to study), but in any case, the "garbage collector" still has a plain understanding.
Even though the "garbage collector is powerful", there are drawbacks. The "garbage collector" only knows to release the memory that is allocated through new, so it does not know how to release the "Special Memory" that your object occupies (objects are allocated some storage space in ways other than "object Generation"), and you need to use the Finalize () function, which allows you to " The garbage collection moment "performs some important (your own) cleanup actions. However, the Finalize function (and perhaps some other related functions) is used in detail and when it is used, I have not actually manipulated it.
In short, there is a very vague understanding of the "garbage collector". Have the opportunity to continue to study further in the future.
Fourth chapter initialization and cleanup