当前位置:网站首页>Application and definition of interface
Application and definition of interface
2022-04-23 03:28:00 【Aiyou coffee】
Interface characterization : Interface cannot be instantiated ; Implementation classes must implement interfaces that are all methods ; Implementation classes can implement multiple interfaces ; Variables in an interface are static constants .
How to use interfaces : Design methods as needed , Implement all methods , Use... In a polymorphic way
The process : Definition Door abstract class ( There's a door , close ), Definition Lock Interface ( locked , The lock )
To write TheftproofDoor class ( Inheritance implementation interface ) Writing test classes ( There is an anti-theft switch to unlock the door )PS: A class can implement multiple interfaces
One . You can define a new interface , use extends To inherit the existing interface
You can define a new interface , use implements To implement all the methods in an interface
You can define a new interface , use implements To implement some methods in an interface
Two .C++ Support for multiple inheritance ,Java Support for single reinheritance ;C++ The danger of multiple inheritance is that a class may inherit different implementations of the same method , Will cause the system to crash ,Java A class in can inherit only one class , But multiple interfaces can be implemented at the same time , That is, the effect and function of multiple inheritance can be realized , The danger of multiple inheritance can also be avoided
3、 ... and . Defining a class inside another class is called an inner class . PS: External classes cannot directly use members and methods of internal classes , If the external class and the internal class have the same member variables or methods, the internal class .
Default member variable or method internal class , If you want to access the member variables of an external class , need this keyword
Four . Access the inner class in the outer class
grammar : Inner class External class objects = new External class ();
External class , Inner class Inner class object = External class objects new Inner class ();
5、 ... and . Inner class Static inner class
grammar new External class . Inner class () Syntax name
External class class name , Inside Inner class object name = new External class class name . Inner class class name ();
( Use static Declared inner class , Non accessible static External properties of )
No variables in the interface are constants , Because the default final
If a class has no parent , Then its parent is Object
The phone has three interfaces : Play , photograph , Connect to the network
版权声明
本文为[Aiyou coffee]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220619008863.html
边栏推荐
- Huawei mobile ADB devices connection device is empty
- 批量下载文件----压缩后再下载
- 集合之List接口
- Knowledge of software testing~
- PWA I'm here
- 7-3 poly width
- Five tips for cross-border e-commerce in 2022
- Why is bi so important to enterprises?
- Unity knowledge points (common core classes)
- 2022 group programming ladder simulation l2-1 blind box packaging line (25 points)
猜你喜欢
Iotos IOT middle platform is connected to the access control system of isecure center
New ORM framework -- Introduction to beetlsql
Section 1 array and slicing in Chapter 6
L3-011 direct attack Huanglong (30 points)
Huawei mobile ADB devices connection device is empty
MySQL keyword group_ Concat, combined connection query
. net webapi access authorization mechanism and process design (header token + redis)
浅学一下I/O流和File类文件操作
2022 group programming ladder simulation match 1-8 are prime numbers (20 points)
关于idea调试模式下启动特别慢的优化
随机推荐
Section 1 array and slicing in Chapter 6
Supersocket is Use in net5 - concept
2022 团体程序设计天梯赛 模拟赛 L1-7 矩阵列平移 (20 分)
Database SQL -- simulate inserting a large amount of data, importing / exporting database scripts, timestamp conversion and database basics
Unity games and related interview questions
PYMOL-note
QT uses drag and drop picture to control and mouse to move picture
MySQL grouping query rules
JS takes out the same elements in two arrays
Section 2 map and structure in Chapter 6
Chapter VI, Section III pointer
Database - MySQL -- Navicat import SQL error 1067 - invalid default value for 'paydate‘
Unity knowledge points (ugui)
Experiment 5 components and event handling
Romantic silhouette of L2-3 of 2022 group programming ladder Simulation Competition (25 points)
Visual programming - Experiment 2
Scenario Title: how does system a use the page of system B
JS implementation of new
IDEA查看历史记录【文件历史和项目历史】
oracle 查询外键含有逗号分隔的数据