public class Something {
   public static void main(String[] args) {
       Other o = new Other();
       new Something().addOne(o);
   }
   public void addOne(final Other o) {   //为什么加上final会没有错呢?怎么样才能有错呢
       o.i++;
   }
}
class Other {
   public int i;
}

解决方案 »

  1.   

    这个哪里错了
    interface  A{
       int x = 0;
    }
    class B{
       int x =1;
    }
    class C extends B implements A {
       public void pX(){
          System.out.println(x);
       }
       public static void main(String[] args) {
          new C().pX();
       }
    }
      

  2.   

    还有这个
    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());
        }
    }
      

  3.   

    因为final修饰的对象所以只是说对象的引用指向的对象本身不可改变,但对象的值日可以改变
      

  4.   

    final修饰对象只是对象的引用不可以改变 对象的内容可以改变呵呵
      

  5.   

    final关键字
    1).修饰class  ==>该类不可继承
       final class A{}
       class B extends A{}   //错误
    2).修饰方法   ==>该方法不能覆写(overwritten)
         class A{
            final void fun(){}
         }    class B extends A{
           final void fun(){}   //error
        }3).修饰变量
         a). 基本类型   ==>值不能改变
              final int x = 123;  
              x++;  //error
         b). 对象类型   ==>引用不能改变
              final MyClass cls = new MyClass();
              cls.xyzField++;   //OK
              cls = new MyClass();  //error
      

  6.   

    谢谢楼上的各位
    关于第二个,c继承b,实现接口X不会被覆盖吗