本帖最后由 刘学 于 2012-9-11 14:25 编辑
interface Playable {
void play();
}
interface Bounceable {
void play();
}
interface Rollable extends Playable, Bounceable {
Ball ball = new Ball("乒乓球");
}
public class Ball implements Rollable {
private String name;
public Ball(String name) {
this.name = name;
}
public String getName() {
return name;
}
@Override
public void play() {
// TODO Auto-generated method stub
ball = new Ball("Football"); //ball是从上面继承的,哪错了
System.out.println(ball.getName());
}
public static void main(String[] a){
Ball ball = new Ball("Football");
ball.play();
}
}
//今天翻书是看到了接口例子,练习一下,出现错误了。
//哪错了,帮看看
//接口看过很长时间了,有点忘了,还得复习一下。
|
|