7 Object-oriented
7.1 Classes and objects
7.2 member variables and local variables
7.2.1 Range of Action
member Variables act on the entire class.
A local variable acts on a method or statement.
7.2.2 in-memory locations
member variables in heap memory
local variables in stack memory
7.3 Anonymous Objects
cannot create object name: New Car ();
an anonymous object is a simplified form of an object
7.3.1 Use Cases
1. Only one call is made to the method of the object
2. Passing as the actual parameter
7.4 Constructors
7.4.1 Features
7.4.2 Effect
Initializing objects
7.4.3 Call
when an object is established, it is automatically called and executed only once.
calls between multiple constructors, using the This keyword: this ([parameter, ...] ); [] means dispensable. This can only be defined in the first row of the constructor, and the initialization action is performed first
7.5 this keyword
Represents the reference to the object to which the function belongs
7.5.1 Effect
7.6 Default Constructors
When there is no constructor in the class, the system defaults to the constructor for the class to add an empty argument to facilitate initialization of the class.
When a constructor is defined in a class, the default constructor has no
7.7 Building Code Blocks
7.7.1 says
{}, the code is written inside {}.
7.7.2 effect
Initializing objects
7.7.3 Call
An object is executed as soon as it is established, and takes precedence over a constructor function.
7.7.4 the difference between constructing code blocks and constructors
This article is from the "Java Basics" blog, so be sure to keep this source http://8163413.blog.51cto.com/8153413/1690320
The seventh chapter object-oriented (i.)