Thanks so much for any hints on what I am missing here my friends, but check out the small code sample on p. 463 of Chapter 8 on "Inner Classes." I can't for the life of me figure out the purpose of the makeInner() method starting on line 3. It does absolutely nothing, but throw me off from trying to understand the real point of what K&B are trying to convey.
I tried taking the method out and the code still compiles and runs with the exact same results as printed in the book.
Nor is there any text in there that says "be careful of questions that try to throw you off with do-nothing code.." or anything like that.
Thanks so much to anyone who can explain this.
--BobN
class MyOuter {
private int x = 7;
public void makeInner() {
MyInner in = new MyInner();
in.seeOuter();
}
class MyInner {
public void seeOuter() {
System.out.println("Outer x is " + x);
System.out.println("Inner class ref is " + this);
System.out.println("Outer class ref is " + MyOuter.this);
}
}
public static void main (
String[] args) {
MyOuter.MyInner inner = new MyOuter().new MyInner();
inner.seeOuter();
}
}