java interface的一个经典实例
来源:互联网 发布:mysql c开发工具 编辑:程序博客网 时间:2024/04/25 15:49
本文转自 http://blog.chinaunix.net/u/22381/showart_251790.html
import java.io.*;
interface CAR
{
void start();
void stop();
}
{
void start();
void stop();
}
class SmallCar implements CAR
{
public void start()
{
System.out.println("smallcar start...");
}
public void stop()
{
System.out.println("smallcar stop!");
}
}
class BigCar implements CAR
{
public void start()
{
System.out.println("bigcar start...");
}
public void stop()
{
System.out.println("bigcar stop!");
}
}
{
public void start()
{
System.out.println("smallcar start...");
}
public void stop()
{
System.out.println("smallcar stop!");
}
}
class BigCar implements CAR
{
public void start()
{
System.out.println("bigcar start...");
}
public void stop()
{
System.out.println("bigcar stop!");
}
}
class TestCar
{
public void operCar(CAR c)
{
c.start();
c.stop();
}
}
public class TestInterface
{
public static void main(String[] args)
{
TestCar tc=new TestCar();
SmallCar sc=new SmallCar();
BigCar bc = new BigCar();
tc.operCar(sc);
tc.operCar(bc);
}
}
{
public void operCar(CAR c)
{
c.start();
c.stop();
}
}
public class TestInterface
{
public static void main(String[] args)
{
TestCar tc=new TestCar();
SmallCar sc=new SmallCar();
BigCar bc = new BigCar();
tc.operCar(sc);
tc.operCar(bc);
}
}
发表于: 2007-03-01,修改于: 2007-03-01 16:51,已浏览3410次,有评论5条 推荐 投诉 网友: 本站网友 时间:2008-09-01 11:16:04 IP地址:210.76.124.★
class TestCar
{
public void operCar(CAR c)
{
c.start();
c.stop();
}
}
- java interface的一个经典实例
- Java中 接口 interface的作用——经典实例
- 一个经典的Makefile实例
- JAVA基础的interface与inheritance实例
- 一个经典的linux多线程实例
- java interface 接口 及 接口的调用 实例及误区
- Java日志框架——一个经典的Logback配置实例
- Java的一个编译错误解决方法:需要class interface enum
- 一个Java后台程序的实例
- Java的一个IO实例
- 一个Java后台程序的实例
- JAVA多线程的一个实例
- 一个Java高手的实例
- JAVA多线程的一个实例
- 一个Java后台程序的实例
- java多线程经典实例
- java多线程经典实例
- Java反射经典实例
- VC++中的小技巧
- 如何考公务员的建议~~~~超级专业,先存着以后绝对用得着,不用满世界的找咯
- 抽象类
- JavaScript乱码问题(个人经验,不知道是否通用)
- Oracle面试题
- java interface的一个经典实例
- FreeTextBox使用详解
- POJ 滑雪
- sql语句查询时is not null 的使用
- 创建mysql数据库
- 设置Double类型数值对象的小数后位数
- 排名 hdu1236
- HP's Growth
- 小小的我,迈开了人生的第一步