[Learning Notes] Thinking In Java (Third Edition) Chapter 4 Initialization & Cleanup

xiaoxiao2021-03-06  27

Constructor: The constructor is to ensure that each object can be initialized. It is automatically adjusted when the Java object has just created and the user is still too late.

use. The name of the constructor is the name of the class, and it can also have parameters. The default constructor is a configuration function that has no parameters. If you write

A class that does not construct a function, the compiler will automatically create a default constructor for you.

Method Overloading: The same name is different. The name is the same, but the parameters are different, even if the parameter order is reversed, it is enough to separate the two methods.

Come, you can also use the return value overload. The overload of the method is necessary, such as when we need two constructor.

The THIS keyword can only be used inside the method, responsible for returning the reference to calling this method. The parameter name and class name can be solved with this. You can use

THIS call constructor.

The Meaning of Static's meaning is that this method does not have this method. You can call the Static method to use the Static method to use the Static method to use the Static method to use the Static method to send to the object with the Static method.

Message. The class STATIC method can only access other Static methods and Static objects.

When the Java garbage collection mechanism contains some special objects in memory, if not the memory allocated by NEW. (Garbage collector only know how to release new allocation

Inner). You must use a Finalize () method provided by Java. Save 1. Objects do not necessarily be used by garbage collection .2. Garbage recycling is not a destricted .3. Garbage recycling is only related to memory It must be remembered that all activities related to garbage recovery (such as garbage collectors and finalize () methods are those not processed

Memory recovery (release memory). Garbage recycling and finalize () are reliable, as long as JVM has not yet to exhaust, it

It is not a waste of time to recycle garbage to recycle memory.

转载请注明原文地址:https://www.9cbs.com/read-69843.html

New Post(0)