In method body, local variable a & b override memeber variable a & b, so you can not access them. If you want to do that, use the key word: this please. For example, this.a & this.b.

解决方案 »

  1.   

    public void set(int a,int b){Synchronized(b){return this.a=a;this.b=b;}}
    why is there a retrun statement?(void.)
      

  2.   

    Oh very sorry! that't my false
    public void set(int a,int b){Synchronized(b){return this.a=a;this.b=b;}}
    there isn't return
      

  3.   

    1。a,和b是简单类型,不是对象(不是object的子类)
    2。你的代码先return了,故此后面的this.b=b不可能运行,所有提示出错。
      

  4.   

    sychronized只能用在Object和它的派生类上,不能用在primitive类型上。
      

  5.   

    public void set(int a,int b){Synchronized(b){return this.a=a;this.b=b;}}
    那个void就不对啊,不能return啊!
    还有就是你的a和b是基本类型,不是object