java继承
来源:互联网 发布:yum x window system 编辑:程序博客网 时间:2024/04/27 13:50
package com.homework.ch2;public class Instrument {public void play(){}}package com.homework.ch2;public class Piano extends Instrument { public void play(){System.out.println("play the piano!"); }}package com.homework.ch2;public class Violin extends Instrument {@Overridepublic void play() {// TODO Auto-generated method stubSystem.out.println("play the vioin!");}}package com.homework.ch2;import java.util.List;import java.util.ArrayList;public class InstrumentTest {List<Instrument> instruments = new ArrayList<Instrument>();/*** @param args*/public static void main(String[] args) {//Instrument instrument=new Piano();Instrument instrument=new Violin();testPlay(instrument);}public InstrumentTest(List<Instrument> instruments) {super();this.instruments = instruments;}public static void testPlay(Instrument instrument){instrument.play();}}
0 0
- Java继承
- JAVA-继承
- java 继承
- Java继承
- Java 继承
- JAVA继承
- java继承
- java/继承
- java 继承
- java继承
- java继承
- JAVA-继承
- Java继承
- java 继承
- JAVA 继承
- 【继承】 JAVA
- Java继承
- Java继承
- 『黑马程序员』第一话<JAVA基础学习>
- Android下结束进程的方法
- HDU 1229 还是A+B
- (37)JS运动之“分享到”移入移出功能
- Android系统下载管理DownloadManager功能介绍及使用示例
- java继承
- 高端互联网品牌执行提供商
- jquery绑定事件和去除事件绑定
- poj3176
- SpringMVC 返回值的字符转换
- Openfire开发配置,Openfire源代码配置,OpenFire二次开发配置
- POJ 3463 Sightseeing
- 简单排序算法的时间下界
- Matlab使用心得