- package pack;
- class Outer
- {
- int x = 3;
- void method(){
- int y = 4;//这句我没有用final修饰
- class Inner{
- void function(){
- System.out.println(y);
- }
- }
- new Inner().function();
- }
- }
- class InnerClassDemo3 {
- public static void main(String[] args) {
- Outer out = new Outer();
- out.method();
- out.method();
- }
- }
复制代码
|
|