07-01 Java encapsulation

1:成员变量和局部变量的区别

2: If you see that the parameter required by a method is a class name, you should know that what is actually required here is a specific object.

3: Anonymous object

4:封装和private

Private export

Encapsulation and use of private

6:this关键字和内存图解

Use this keyword

This memory diagram:

7: Construction method

Construction method

Overloading of construction methods and precautions

8. Member method

9. Code and test of a standard student class

10. Code: Student s = new student(); What did you do?

What did you do to create the object?

Illustration:

11. When a variable is defined as a member variable: if the variable is used to describe the information of this class, the variable should be defined as a member variable.

Where is the definition of variables? The smaller the range of variables, the better. Because it can be recycled in time.

Length and width are information describing the class of rectangle, which should be defined as member variables:

12. Static keyword

Introduction of static

Static features

Static memory diagram:

Static precautions;

Format of main method

Operation results:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>