public class Ball implements Rollable{
public static void main(String[] args) {
Ball ball = new Ball("lanqiu");
System.out.println(ball.getName());//这里程序为何不报错?如何区分新实例ball和接口中的ball
ball.play();
Rollable.ball.play();
}
private String name;
public String getName(){
return name;
}
public Ball(String name){
this.name = name;
}
@Override
public void play() {
// ball = new Ball("Football");
System.out.println(ball.getName());
}
}
interface Playable{
void play();
}
interface Bounceable{
void play();
}
interface Rollable extends Playable,Bounceable{
Ball ball = new Ball("PingPang");
}