class ?Outer?{private ?int ?x=3;?? class ?inner//內(nèi)部類。 { void ?function() { System.out.println("inner:"+Outer.this.x); } } void ?method() { Inner ?in=new ?Inner(); in.function(); }?} ? class ? InnerClassDemo { public ? static ?void ? main(String[] ?args) {? ?// ? Outer ?out=new ? Outer();? ?// ?out.method(); ?? Outer.Inner ?in=new ?Outer().new ?Inner(); ? in.function(); } }
添加回答
舉報(bào)
0/150
提交
取消