A question: in the following code, taken from SB6 Chapter 8 Self Test, I understand how to access the enclosing class method drive() from the inner class constructor and the initializer block.
but if I make a new instance of the enclosing class from within the inner class, I'm confused as to why I can't call the same method using that reference.
posted 5 years ago
It will work if you call it from some block or method. Whether its an inner class or whatever you cannot call methods in a class where you can make only declarations or define methods.
I have added a works method and called c.drive() from there.