To ensure initialization, Java object creation and initialization is the same concept, you can't have this.
Method of overloading distinguishing method: a list of unique parameter types
Constructor: If there is no constructor, the compiler will help you create a non-parameter type constructor, but if you construct one, then
No matter what you construct, the compiler will not help you.
THIS Usage: This is only applied to those, you clearly specify the special circumstances of the Reference to use the current object. For example, he is often used in
Return statement to return the current object's Reference.
/
Public Class Testthis
{
INT i = 0;
Testthis increment ()
{
i ;
Return this;
}
Void print ()
{
System.out.println ("i =" i);
}
Public static void main (string [] args)
{
Testthis x = new testthis ();
x.increment.increment.increment.print (); // i == 3
}
}
/
The compiler will not let you call the constructor in the method, but the constructor can be called in the constructor. This time you can use this.
To make this call.
The name of the parameter and the name of the class data member (sometimes deliberately), you can use this.x to represent he is
Data members, not parameters.
STATIC usage: Is it true "OOP", leave it to the theorist.
Garbage recycling and finalize () are all reliable. And it is a problem with their places and timings. Do not be too concerned about. One point to know
System.gc () can enforce Finalize ();
Members' initialization: Basic data type, if the local variable defined inside the method, the initialization will be wrong, and if it is the data
Members, they are not initialized, and the compiler will automatically load the initial value.
Below is a summary of basic creation objects, use DOG as an example:
1. The object of the first creation of the DOG class (the constructor is actually a static method), or the first time to access the Static's Static method or
When the field is in the field, the Java interpreter will search for ClassPath and find dog.class.
2, after loading Dog.Class, all STIC data is initialized. When this is the first to load the Class object,
The initialization of Static members.
3. When you create a new object with new (), the creation process of the Dog object will first assign enough memory to the object in the heap.
4, this fast memory first is cleared, so that automatically assigns a member of the DOG object's Primitive type of the Dog object (for the number is zero, or the corresponding Boolean and char), set the Reference to NULL.
5. Execute the initialization when defining member data.
6, perform constructor.
OK, today, here will learn "hidden implementation" and "multiplex" tomorrow