本帖最后由 钱兆元 于 2012-1-31 20:44 编辑
下面这段代码哪里错了?求教- 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");
- System.out.println(ball.getName());
- }
- }
复制代码 |