Name: bk70084 Date: 07/20/98
Try running the following code. The bang() function
in bar2 will cause a NullPointerException, even though the
access is completely correct. I would guess it has something to
do with the subclassing from bar1, which is not an inner class
class bar1 {
bar1() {
bang();
}
void bang() {
}
}
class foo {
String i = "hi";
class bar2 extends bar1 {
bar2() {
super();
}
void bang() {
System.out.println("outer instance is "+foo.this); // will print null
System.out.println("i is "+i); // will throw NullPointerException
}
}
foo() {
new bar2();
}
public static void main(String argv[]) {
new foo();
}
}
(Review ID: 29780)
======================================================================