当前位置:网站首页>Freshman summer internship Day5_ two
Freshman summer internship Day5_ two
2022-07-23 05:36:00 【CHY resounding】
Catalog
9. How to divide inheritance tree and interface , The idea is crucial , Be concise and efficient
1. Guide pack :


2.
Shortcut key ,shift+fn+f6 You can select the variable you click on and select all the places where this variable appears , Unified modification .
3.
alt+ enter , Automatic guiding package ;ctrl + shift + u Capitalize
4.
final:


enhance readability :

5. Permission modifier :


6. Code block :
(1) Local code block : End the life cycle of local variables in advance , Recycle after use , It's not often used now
(2) Building blocks of code : It's eliminated , inflexible


So now it is generally improved to :

(3)

Apply to data initialization :

Written in static It also prevents this method from being called repeatedly, resulting in new
7. abstract class



Abstract class constructor function :![]()

8. Interface
(1) Different from abstract classes 
(2) Format :



(3) characteristic :

(4) Using memory analysis tools : Black horse programmer Java Zero Basics Video Tutorial (2022 newest Java introduction , Including Stanford exercises + Force button algorithm problem + Big factory java Interview questions )_ Bili, Bili _bilibili

(5) Abstract methods with multiple interfaces with identical names , We can rewrite it once
(6) Summary :
![]()

9. How to divide inheritance tree and interface , The idea is crucial , Be concise and efficient

10. New feature expansion :



So if show Is static , Then implement the show It's not called rewriting , Just like the name
Can pass infer.show(),inferImpl.show() Respectively called
11.jdk9



12. Interface polymorphism !

13. Adapter :

InterAdapter As the transition is empty
interImpl Change the implementation class to inheritance interadapter, Then rewrite whichever method you need .
14. Inner class


(1) Member inner class


![]()
Permissions are the same as above ,private< Default <protected<public



If the inner class is private , If you need to get it , Or put private Changed , Or just like the figure below , Return by method :


In fact, the internal source code of the iterator also operates in this way :

Now consider duplicate names :
If there is no duplicate name :
Obviously, what you get is what the arrow points to a
Otherwise, it needs to be like this :( Similar to inheritance , Only that super Changed )

Memory analysis , That's true : Still from the stack , Pile up , Method area analysis

First, enter the red line , Then put outer,inner Class bytecode file is loaded first , among ,outer and Inner It's separate.
Look at the picture below :( The bytecode file is in Out In file )
This is the result of compilation , It's separate.
So these two chain New It's like this in the stacking area :


Through memory tools, you can see , Local variables of internal classes : There is such a pointer

![]()
summary : 
(2) Static inner class

You want to use non static members of external classes inside static classes , It has to be

![]()

Pay attention to the picture above , Calling static methods with objects can be called , But we do not advocate , So it didn't give a hint .
Call... With the class name :

(3) Local inner classes ( Similar to the properties of local variables , It can be used final Decoration is not available public modification )

usage :

边栏推荐
- 代码随想录笔记_数组_977有序数组的平方
- Debug No4 利用RenderDoc排查bug
- 交换二进制位中的奇偶位
- Some topics such as ctfhub web information disclosure WP CSDN creation punch in
- The heavy performance of karma in the four training of Li Fan
- Several simple and understandable methods of finding prime numbers in C language
- Do you want to have a robot that can make cartoon avatars in three steps?
- Programming Xiaobai's first blog
- Implementation of duilib edit placeholder prompt text
- Get computer hardware information
猜你喜欢
随机推荐
Leetcode-504. Hex number
Print all the words in the string array -- the story of pointer and string
浏览器插件损坏怎么办,删除|安装插件的方法
The heavy performance of karma in the four training of Li Fan
Debug No4 利用RenderDoc排查bug
VRTK功能教学(二):Unity3DVRTK手柄瞬移和UI交互射线切换功能丨3D模型射线交互切换丨直线和曲线的切换
超简单的倒计时代码编写
Leetcode-312. poking balloons
Code random notes_ Linked list_ 206 reverse linked list
交换二进制位中的奇偶位
Bubble sorting in C language
Code random notes_ Array_ 209 subarray with the smallest length
链表的基本操作
Camera picture transformation and first person movement
What to do if the browser plug-in is damaged? How to delete | install the plug-in
Libcurl redirection
Code random notes_ Linked list_ 142 circular linked list II
Unity3D音频系统Aduio声音丨音乐控制丨音频播放丨音频暂停丨音频控制
Notes and reflection notes
leetcode-买卖股票的最佳时机含手续费









