<> Object oriented second day :

<> First day of submarine game :

* establish 6 Class , establish World Class and test
<> The second day of submarine game :

* to 6 Add constructor to class , And test
<> review :

* What is a class ? What is an object ?
* How to create a class ? How to create objects ? How to access members ?
* Overloading of methods (overload):----------------- Convenient user call
* Occurs in the same class , Same method name , The parameter list is different
* The compiler will automatically bind the method according to its signature at compile time
<> note :

* Construction method : Constructor , constructor , Builder --------- Reuse codes that assign initial values to member variables
* effect : Assign initial values to member variables
* Same name as class , No return value type ( even void none )
* Creating (new) Object is called automatically
* If you don't write your own construction method , The compiler provides a parameterless constructor by default , If you write your own construction method , It is no longer provided by default
* Construction methods can be overloaded
* this: Refers to the current object , Which object calls the method, it refers to which object
​ Can only be used in methods , Method before accessing a member variable this.
this Usage of :
*
this. Member variable name ------------- Accessing member variables

When a member variable has the same name as a local variable , If you want to access member variables this Cannot be omitted
class Student { String name; // Member variable ( In the whole class ) int age; String address;
// local variable ( In the current method ) Student(String name,int age,String address){ this.name = name;
this.age = age; this.address = address; } void study(){ System.out.println(name+
" I'm learning ..."); } void sayHi(){ System.out.println(" hello everyone , My name is "+name+", this year "+age+" Years old , Live at home "+
address); } }
*
this. Method name ()----------------- Call method ( understand )

*
this()--------------------------- Call construction method ( understand )

* null: Indicates null , No object points to
If the referenced value is null, Then the reference cannot perform any point operations ,
Occurs if the operation NullPointerException Null pointer exception

<> Essence note :

*
Construction method : Constructor , constructor , Builder --------- Reuse codes that assign initial values to member variables

* effect : Assign initial values to member variables
* Same name as class , No return value type ( even void none )
* Creating (new) Object is called automatically
* If you don't write your own construction method , The compiler provides a parameterless constructor by default , If you write your own construction method , It is no longer provided by default
* Construction methods can be overloaded
*
this: Refers to the current object , Which object calls the method, it refers to which object
​ Can only be used in methods , Method before accessing a member variable this.
this Usage of :

*
this. Member variable name ------------- Accessing member variables

When a member variable has the same name as a local variable , If you want to access member variables this Cannot be omitted

*
this. Method name ()----------------- Call method ( understand )

*
this()--------------------------- Call construction method ( understand )

*
null: Indicates null , No object pointed to
If the referenced value is null, Then the reference cannot perform any point operations ,
Occurs if the operation NullPointerException Null pointer exception

<> supplement :

*
Member variables and local variables can have the same name :
---- The principle of proximity is adopted by default
---- To access member variables , be this Cannot be omitted

*
memory management : from JVM To manage

* heap :new Objects coming out ( Include member variables )
* Stack : local variable ( Include the parameters of the method )
* Method area :---------- The fifth day of object-oriented
*
Member variable : Write in class , Outside method -------- There are default values
local variable : Method ------------------------ No default value

*
An array is also an object , So array objects are also stored in the heap ,
The elements of the array are stored in the heap as member variables

*
Memory map :

*
Tomorrow words :
1)extends: inherit 2)super: super 3)up: Up 4)load: load 5)animal: animal 6)tiger: tiger 7)Sea: ocean 8)
object: object

Technology
©2019-2020 Toolsou All rights reserved,
【C++ Must see for entry 】C++ from 0 reach 1 Introductory programming axios Interceptor packaging and use Spring Boot Interview must ask : Automatic configuration principle VMware 16 install centos 7 Detailed tutorial C Language data structure - Sequence table delete duplicates V2.0.0 The 12th Blue Bridge Cup c++b Group personal problem solving On sending data from serial port single chip microcomputer to upper computer centos7 install RabbitMqjava Polymorphic array of opencv-python Fourier transform and inverse transform