当前位置:网站首页>Day_ thirteen

Day_ thirteen

2022-06-25 16:25:00 grp_ grp_ grp

1. The relationship between classes

Inherit :

key word : extends

Class and class are single inheritance , Interface and interface are multi inheritance ,

 

 

Realization :

key word : implement

There are multiple implementations between classes and interfaces , Multiple are separated by commas Class Class name implements Interface , Interface ....{}

Class implements the interface , All abstract methods must be implemented , Otherwise, it is necessary to add abstract modification

 

rely on :

relation :

polymerization :

Both the whole and the part have independent life cycles

Combine :

Part and whole are inseparable , For example, the human body is a combination

2. Inner class

Definition :

When the inside of a thing , There is another part that needs a complete structure to describe , And this inside The complete structure of the ministry only provides services for external things , Then the whole internal structure is better to make Use inner classes

stay Java in , Allow the definition of one class to be inside another class , The former is called the inner class , The latter is called the outer class .

Inner class It is generally used within the class or statement block that defines it , It must be given the full name when it is externally referenced .

Member inner class :

Static inner class :

 

Local inner classes :

 

  Anonymous inner class :

 
 3. Design patterns  

Starving model :

The load phase creates objects

 

The sluggard model :

        Create objects when you use them

 

 

原网站

版权声明
本文为[grp_ grp_ grp]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202190533360408.html