本帖最后由 袁錦泰 于 2012-6-1 22:36 编辑
- package cn.yuanjintai.base;
- interface Playable {
- void play();
- }
- interface Bounceable {
- void play();
- }
- interface Rollable extends Playable, Bounceable {
- Ball ball = new Ball("PingPang");//<span style="color: Red;">public static final</span> 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());
- }
- }
复制代码 接口这一个部分你如果学得够扎实,这个问题就很容易解释.
被final修饰的变量是不可以在后面重新赋值的.
还有你的代码能不能写得整齐一点,谢谢合作.
|