Sunday, September 24, 2006

Method of private inner class : Accessibility

Not possible to access methods of private inner class as the following code will give compile error.

class MyOuter{
private class MyInner{
public float f(){return 1.2f;}
}
public MyInner getMyInner(){
return new MyInner();
}
}

public class Test13{
public static void main(String... args){
MyOuter o = new MyOuter();
float f = new MyOuter().getMyInner().f();
}
}

No comments: