class InOut{
String str = new String("123");
public void method()
{
int i =2;
final int a =1;
//System.out.println(a);
class Inner
{
public void sayHello()
{
// Cannot refer to a non-final variable i inside an inner class defined in a different method
//System.out.println(i);
System.out.println(a);
}//end of Inner class
}
}//end of method
}
在内部类中的sayHello方法。我们可以访问变量a,但是不能访问变量i作者: 不似侽紸角. 时间: 2014-6-10 23:05