- 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()); }
- }
复制代码 [size=10.000000pt]interface [size=10.000000pt]可继承多个[size=10.000000pt]interfaces[size=10.000000pt]啊,怎么会出错呢?
|
|