this keyword
think in Java: the This keyword can only be used inside a method, representing a reference to the "that object that called the method". Usually this when written, it refers to this object or the current object.
Usage
1. Distinguish the variable with the same name 2. Returns a reference to its own Class 3. Call another constructor in one of the constructor functions of the current class
Code
Public classUser {intA; User () { This(0);//distinguishing variables with the same name} User (inta) { This. A = A;//calling a construction method in a constructor method } PublicUser GetUser () {return This;//returns a reference to its own class }}Note: 1. Only one construction method can be called, and the call action is placed at the top 2. Constructor method cannot be called in another method
Initialization
order (when creating an object): 1. Static variable, static method 2. Member variable, member Method 3. Constructor static variable initialization: 1. When you create an object (New keyword) 2. When you access the object's static data (class.staticdate)
Array
The
array is class, so when we want to use it, we need to initialize it with the New keyword and create a reference.
New= {Type,type};Arrayname is a reference to the type[] array object.
Variable parameter list
A method can have only one variable-length parameter, and the variable-length parameter must be the last parameter of the method
Public class TestClass { publicstaticvoid getString (String ... args) { for (String X:args) { + "\ T");} } Public Static void Main (string[] args) { getString ("Hello", "world", "haha");} } Out:hello World haha
Clean
after watching the garbage cleanup and then write
Refence
http://alexyyek.github.io/2015/01/03/initial/
Initialization and cleanup of Java