本帖最后由 aion2013tian 于 2013-10-23 14:02 编辑
interface Playable {
void play();
}
interface Bounceable {
void play();
}
interface Rollable extends Playable, Bounceable {
Ball ball = new Ball("PingPang");
}
class Ball implements Rollable {
private String name;
public String getName() {
return name;
}
public Ball(String name) {
this.name = name;
}
public void play() {
ball = new Ball("Football"); //编译时出现错误,ball不能被赋值
System.out.println(ball.getName());
}
}
这是为什么啊?求详细解释
|