Sree,
Even if you have access to the
Outer class from
Another class you may or may not have access to the inner class in the
Another class. To put it simple, If the inner class is
private to the outer class then you CANNOT access it from other classes. See the foll example. If I remove the comment a compiler error will occur. You know which error.
<pre>
class Outer {
private class PrivateInner {
}
class PackageInner {
}
void m1() {
PrivateInner privateInner = new PrivateInner();
PackageInner pacakgeInner = new PackageInner();
}
}
class AnotherClass {
void m2() {
Outer outer = new Outer();
//Outer.PrivateInner outerPrivate = outer.new PrivateInner();
Outer.PackageInner outerPaclkage = outer.new PackageInner();
}
}
class
test {
static public void main(
String[] args) {
}
}
</pre>