inner class如何访问同一个包下的其他类的方法
class A{
class Ainner{
public void set(){
}
}
}
class B{
class Binner{
A a=new A();
A.Ainner ainner=a.Ainner();
ainner.set();
}
}
Binner调用set()方法是否正确????
------解决方案-------------------- class A {
class Ainner {
public void set() {
}
}
}
class B {
class Binner {
A a = new A();
A.Ainner ainner = a.new Ainner();
public void test() {
ainner.set();
}
}
}
}
------解决方案--------------------class Outer
{
class Inner
{
public void fun()
{
System.out.println( "come in ");
}
}
Inner getInner()
{
return new B();
}
}
class Outer2
{
class Inner2
{
Outer ot=new Outer();
Outer.Inner in=ot.getInner();
in.fun();
}
}