当前位置:网站首页>Day_ ten
Day_ ten
2022-06-25 16:25:00 【grp_ grp_ grp】
1.This
1.1
this: Is in each object , A reference type variable that holds its own memory address
this It means that the current object
1.2
What can be done :1. In a member method or constructor , Distinguish between member variables and local variables with the same name
this.xxx
2. In the constructor , Overload calls other constructor methods in the current class , But it must be written in the first line of the constructor
this(xxx)
3.return this Returns the memory address of the current object , You can chain call
Who calls this member method ,this Who is the
Be careful this Cannot use static methods
1.3 How to use it?
1.3.1 Distinguish between members and parts




1.3.2 Overloaded call constructor

1.3.3 call chaining

1.4 Be careful
This Cannot appear in a static context
2.Static
2.1 What is it?
Modifier , keyword , Used to distinguish between static and member
2.2 What can be done

2.3 Static statement block

2.4 Instance statement block


3. encapsulation
Put all the components together , You can also hide the data through the permission control modifier , It can control the modification degree of class data by users
Proper encapsulation can make the code easier to understand , Easy to maintain , It improves the security of the code
3.1 Packet mechanism
3.1.1Package

3.1.2Import

Be careful : By space Or when you return the train Automatic package Guide , If the program is OK , But the report is wrong , You can see
Check to see if there is a package import error

3.2 Access control



4. Inherit
4.1 What is it?

4.2 What can be done

4.3 How to use it?
grammar : class Class name extends Parent class name { The class body }



5.Super
5.1 What is it?
super : The official saying is Represents the characteristics of the parent class
5.2 What can be done

5.3 How to use it?
5.3.1 Distinguish attributes with the same name of parent and child classes


5.3.2 Call the father's constructor



5.4 Be careful
If in the subclass constructor , No display appears super() It didn't show up this(xxx) be There is one by default super() Call the parent nonparametric construct
also super(xxx) Must appear in subclass constructor first line therefore this(xxx) and super(xxx) Not at the same time
Because the first line of the construction method has super() Call the parent class construct , therefore If the constructor of a class is privatized , Then the class will no longer be inherited
6. overwrite / rewrite
6.1 What is it?

overwrite Specific member method , That is to say Only member methods You can override
6.2 Application scenarios
When the function of the parent class cannot meet the needs of the child class , Overwrite .

边栏推荐
- Practice of geospatial data in Nepal graph
- error Parsing error: Unexpected reserved word ‘await‘.
- GridLayout evenly allocate space
- The style of the mall can also change a lot. DIY can learn about it!
- Gold three silver four, an article to solve the resume and interview
- Webgl and webgpu comparison [4] - uniform
- Linux-MySQL数据库之高级SQL 语句一
- Swift responsive programming
- Unity技术手册 - 生命周期内大小(Size over Lifetime)和速度决定大小(Size by Speed)
- Nsurlsession learning notes (III) download task
猜你喜欢

Beginner bug set

赫尔辛基交通安全改善项目部署Velodyne Lidar智能基础设施解决方案

Swift responsive programming

Alvaria宣布客户体验行业资深人士Jeff Cotten担任新首席执行官

AutoK3s v0.5.0 发布 延续简约和友好

Go language - lock operation
Why does golang's modification of slice data affect the data of other slices?

Detailed explanation of IVX low code platform series -- Overview (I)
Practice of geospatial data in Nepal graph

Overall MySQL architecture and statement execution process
随机推荐
不要小看了积分商城,它的作用可以很大!
一文带你搞懂 JWT 常见概念 & 优缺点
White screen, how fouc is formed, and how to avoid it
Most commonly used SQL statements
f_ Read function [easy to understand]
Reverse series to obtain any wechat applet code
TensorFlow加载cifar10数据集
说下你对方法区演变过程和内部结构的理解
mysql整体架构和语句的执行流程
One minute to familiarize yourself with the meaning of all fluent question marks
Webgl and webgpu comparison [4] - uniform
[untitled]
Sleep formula: how to cure bad sleep?
八种button的hover效果
Practice of geospatial data in Nepal graph
Classic deadlock scenario of multithreading and its solution (philosopher dining problem)
Golang open source streaming media audio and video network transmission service -lal
Android修行手册之Kotlin - 自定义View的几种写法
Mixed density network (MDN) for multiple regression explanation and code example
Principle analysis of ThreadLocal source code