class Outer
{
int x = 5;
void function()
{
final int y = 8; //function()内的局部变量,只有被final修饰后才能被同为function()内的类访问。
class Inner
{
void method()
{
System.out.println(y);
}
}
new Inner().method();
}
}
class Test2
{
public static void main(String[] args)
{
new Outer().function();
}
}
| 欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |