当前位置:网站首页>理解:什么是接口,接口的概念
理解:什么是接口,接口的概念
2022-07-17 00:14:00 【荼蘼_】
接口
1.在代码中,包含【访问修饰符】 interface 接口名 {接口的成员}代码即为接口。
2.接口的成员中只包括 常量 和 抽象方法。
3.使用:一个接口可以继承多个接口,一个类可以实现多个接口。
如继承(extends):
public interface Interface2 extends Interface1{
接口的成员
} 如实现(implement ):
public class ClassName implement Interface1,Interface2{
实现接口Interface1的方法1
实现接口Interface2的方法2
} 4.接口不是类,不能被实例化,没有构造方法。
5.理解:什么是接口?
接口中定义了常量以及抽象方法,能够弥补java中单一继承的模式,但是其中的方法只是声明,并不能实现。
可以把接口理解为硬件中的USB接口,能够连接更多的硬件,扩展更多的使用模式,既方便又高效。
边栏推荐
- STL -- vector container
- 字符串全排列问题
- [tools] unity2d character controller, which controls 2D players to move and jump in four directions and horizontal directions
- 【Unity开发小技巧】Unity混音器Mixer控制全局音量
- bugku---game1
- 转载:SQL注入常见绕过
- 【Unity开发小技巧】Unity打包PC端exe,压缩打包为一个exe文件
- Gdb+vscode for debugging 3 - vscode and GDB remote debugging
- 使用JMeter测试基于WebSocket协议的服务
- php伪协议实现命令执行
猜你喜欢

Visual studio 2019-qt debugging

ENVI_IDL:读取OMI数据(HDF5)并输出为Geotiff文件+详细解析

Vmware Tools最新安装教程(RHEL8)

攻防世界----easytornado笔记

Visual Studio 2019-QT调试

Hash table, bloom filter, distributed consistency hash

元宇宙公链Caduceus项目详解(一):Caduceus Metaverse Protocol的项目理念及技术框架

【Unity开发小技巧】Unity打包PC端exe,压缩打包为一个exe文件

ENVI_IDL:批量对Modis Swath产品进行均值运算+解析

Unity导入fbx模型后,运行时物体的旋转和位置自动改变的问题解决方法
随机推荐
Logical vulnerability - authentication vulnerability
[tools] unity screen drawing line, unity screen drawing Hsj drawing tool
树和堆知识点总结
LeetCode:动态规划中的多重背包问题【一个模板解决所有~】
STL -- map container
【Unity编辑器扩展】显示资源目录下所有文件所占内存大小
Visual Studio 2019-QT调试
STL--map容器
【工具篇】SQLite本地数据库在Unity3D的应用
剑指 Offer 48. 最长不含重复字符的子字符串
动态规划问题 - 小兵向前冲
Lintcode 366:Fibonacci 斐波那契数列
Gdb+vscode for debugging 7 - how to debug when there is a segmentation default/ segment error in the program?
[tools] unity2d character controller, which controls 2D players to move and jump in four directions and horizontal directions
Stl--queue container
ENVI_ Idl: batch splice the daily data of MODIS swath and output it in GeoTIFF format
STL -- string container
Lecture 2 BTC cryptography principles (notes)
Buaaos-lab0 experimental report
(附word操作以及视频讲解)使用ARCGIS进行地图配准_投影变换_普通地图制作_专题地图制作