l,k,iLocal classes Can access all the features of the enclosing class (because they are defined inside the method of the class) but can access only final variables defined inside the method (including method arguments). This is because the class can outlive the method, but the method local variables will go out of scope – in case of final variables, compiler makes a copy of those variables to be used by the class.

解决方案 »

  1.   

    jimw(),你说:"in case of final variables, compiler makes a copy of those variables to be used by the class. "我不太明白啊,你的意思是不是编译器会给方法里的常量留个备份以便在方法结束后给类使用吗?如果是这个意思的话,那么怎么访问方法体里定义的常量啊?
      

  2.   

    奥是不是把final int i = 99;改为int i = 99;后 i就invisible了??
    primitive varaible不是值传递吗??
      

  3.   

    撤哪里去了,这个问题和pass-by-value有关吗?
      

  4.   

    jimw(),你说:"in case of final variables, compiler makes a copy of those variables to be used by the class. "我不太明白啊,你的意思是不是编译器会给方法里的常量留个备份以便在方法结束后给类使用吗?如果是这个意思的话,那么怎么访问方法体里定义的常量啊? 
      

  5.   

    l,k,i一个method的final的local field,在该method内的内部类(local class)
    中是visible的,否则不是visible的,嘻嘻
      

  6.   

    因为j不是final的,所以不能用于local class,语法上是这样规定的,
    具体原因不知道,嘻嘻