接口interface
来源:互联网 发布:maven 设置java home 编辑:程序博客网 时间:2024/05/27 03:29
1.接口interface 接口可以理解为一种特殊的类,里面全部是由全局常量和公共的抽象方法所组成
2.接口的格式
interface interfaceName {
全局常量
抽象方法
}
3.接口的实现必须通过子类使用关键字implements,可以多实现 和单继承不同。
interface Inter{<span style="white-space:pre"></span>public abstract void name() ;<span style="white-space:pre"></span>}<span style="white-space:pre"></span>interface Inter2{<span style="white-space:pre"></span>public abstract void say2() ;<span style="white-space:pre"></span>}<span style="white-space:pre"></span>//接口可以實現多繼承<span style="white-space:pre"></span>interface Inter3 extends Inter,Inter2{<span style="white-space:pre"></span>public abstract void say3() ;<span style="white-space:pre"></span>}<span style="white-space:pre"></span><span style="white-space:pre"></span>//同样可以实现接口的多实现<span style="white-space:pre"></span>class A implements Inter3{<span style="white-space:pre"></span>public void name(){<span style="white-space:pre"></span><span style="white-space:pre"></span>}<span style="white-space:pre"></span>public void say2() {<span style="white-space:pre"></span><span style="white-space:pre"></span>}<span style="white-space:pre"></span>public void say3() {<span style="white-space:pre"></span><span style="white-space:pre"></span>}<span style="white-space:pre"></span>}
0 0
- 接口 interface
- Interface-接口
- 接口 interface
- 接口interface
- interface 接口
- interface 接口
- 接口 interface
- 接口 interface
- interface接口
- 接口interface
- 接口interface
- 接口interface
- 接口(Interface)
- 接口 interface
- 接口interface
- 接口interface
- 接口interface
- interface接口
- 每个设计师需知的40个设计素材站
- action中调用Spring 注解 service 总是为空
- 工厂模式原理及其简单应用
- Apache Cordova-Android框架原理研究笔记 II
- 设计模式系列(七)——命令模式
- 接口interface
- 机器学习算法的Python实现 (1):logistics回归 与 线性判别分析(LDA)
- Canny算子中的非极大值抑制(Non-Maximum Suppression)分析
- 动态规划算法解最长公共子序列LCS问题
- Fragment+FragmentTabHost实现仿新浪微博底部菜单栏
- leetcode--求区间内的元素个数
- AdminLTE 入门教程
- linux java Cannot allocate memory
- netstat